Passed
Push — master ( 0e355f...67b901 )
by Brian
04:33
created
includes/payments/class-getpaid-payment-form.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -72,28 +72,28 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74 74
 	 */
75
-	public function __construct( $form = 0 ) {
76
-		parent::__construct( $form );
75
+	public function __construct($form = 0) {
76
+		parent::__construct($form);
77 77
 
78
-		if ( is_numeric( $form ) && $form > 0 ) {
79
-			$this->set_id( $form );
80
-		} elseif ( $form instanceof self ) {
78
+		if (is_numeric($form) && $form > 0) {
79
+			$this->set_id($form);
80
+		} elseif ($form instanceof self) {
81 81
 
82
-			$this->set_id( $form->get_id() );
82
+			$this->set_id($form->get_id());
83 83
 			$this->invoice = $form->invoice;
84 84
 
85
-		} elseif ( ! empty( $form->ID ) ) {
86
-			$this->set_id( $form->ID );
85
+		} elseif (!empty($form->ID)) {
86
+			$this->set_id($form->ID);
87 87
 		} else {
88
-			$this->set_object_read( true );
88
+			$this->set_object_read(true);
89 89
 		}
90 90
 
91 91
         // Load the datastore.
92
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
92
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
93 93
 
94
-		if ( $this->get_id() > 0 ) {
95
-            $this->post = get_post( $this->get_id() );
96
-			$this->data_store->read( $this );
94
+		if ($this->get_id() > 0) {
95
+            $this->post = get_post($this->get_id());
96
+			$this->data_store->read($this);
97 97
         }
98 98
 
99 99
 	}
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 * @param  string $context View or edit context.
121 121
 	 * @return string
122 122
 	 */
123
-	public function get_version( $context = 'view' ) {
124
-		return $this->get_prop( 'version', $context );
123
+	public function get_version($context = 'view') {
124
+		return $this->get_prop('version', $context);
125 125
     }
126 126
 
127 127
     /**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @param  string $context View or edit context.
132 132
 	 * @return string
133 133
 	 */
134
-	public function get_date_created( $context = 'view' ) {
135
-		return $this->get_prop( 'date_created', $context );
134
+	public function get_date_created($context = 'view') {
135
+		return $this->get_prop('date_created', $context);
136 136
     }
137 137
 
138 138
     /**
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 * @param  string $context View or edit context.
143 143
 	 * @return string
144 144
 	 */
145
-	public function get_date_created_gmt( $context = 'view' ) {
146
-        $date = $this->get_date_created( $context );
145
+	public function get_date_created_gmt($context = 'view') {
146
+        $date = $this->get_date_created($context);
147 147
 
148
-        if ( $date ) {
149
-            $date = get_gmt_from_date( $date );
148
+        if ($date) {
149
+            $date = get_gmt_from_date($date);
150 150
         }
151 151
 		return $date;
152 152
     }
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @param  string $context View or edit context.
159 159
 	 * @return string
160 160
 	 */
161
-	public function get_date_modified( $context = 'view' ) {
162
-		return $this->get_prop( 'date_modified', $context );
161
+	public function get_date_modified($context = 'view') {
162
+		return $this->get_prop('date_modified', $context);
163 163
     }
164 164
 
165 165
     /**
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 	 * @param  string $context View or edit context.
170 170
 	 * @return string
171 171
 	 */
172
-	public function get_date_modified_gmt( $context = 'view' ) {
173
-        $date = $this->get_date_modified( $context );
172
+	public function get_date_modified_gmt($context = 'view') {
173
+        $date = $this->get_date_modified($context);
174 174
 
175
-        if ( $date ) {
176
-            $date = get_gmt_from_date( $date );
175
+        if ($date) {
176
+            $date = get_gmt_from_date($date);
177 177
         }
178 178
 		return $date;
179 179
     }
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 	 * @param  string $context View or edit context.
186 186
 	 * @return string
187 187
 	 */
188
-	public function get_name( $context = 'view' ) {
189
-		return $this->get_prop( 'name', $context );
188
+	public function get_name($context = 'view') {
189
+		return $this->get_prop('name', $context);
190 190
     }
191 191
 
192 192
     /**
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 	 * @param  string $context View or edit context.
197 197
 	 * @return string
198 198
 	 */
199
-	public function get_title( $context = 'view' ) {
200
-		return $this->get_name( $context );
199
+	public function get_title($context = 'view') {
200
+		return $this->get_name($context);
201 201
 	}
202 202
 
203 203
     /**
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 * @param  string $context View or edit context.
208 208
 	 * @return int
209 209
 	 */
210
-	public function get_author( $context = 'view' ) {
211
-		return (int) $this->get_prop( 'author', $context );
210
+	public function get_author($context = 'view') {
211
+		return (int) $this->get_prop('author', $context);
212 212
     }
213 213
 
214 214
     /**
@@ -218,21 +218,21 @@  discard block
 block discarded – undo
218 218
 	 * @param  string $context View or edit context.
219 219
 	 * @return array
220 220
 	 */
221
-	public function get_elements( $context = 'view' ) {
222
-		$elements = $this->get_prop( 'elements', $context );
221
+	public function get_elements($context = 'view') {
222
+		$elements = $this->get_prop('elements', $context);
223 223
 
224
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
225
-            return wpinv_get_data( 'sample-payment-form' );
224
+		if (empty($elements) || !is_array($elements)) {
225
+            return wpinv_get_data('sample-payment-form');
226 226
 		}
227 227
 
228 228
 		// Ensure that all required elements exist.
229 229
 		$_elements = array();
230
-		foreach ( $elements as $element ) {
230
+		foreach ($elements as $element) {
231 231
 
232
-			if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
232
+			if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) {
233 233
 
234 234
 				$_elements[] = array(
235
-					'text'    => __( 'Select Payment Method', 'invoicing' ),
235
+					'text'    => __('Select Payment Method', 'invoicing'),
236 236
 					'id'      => 'gtscicd',
237 237
 					'name'    => 'gtscicd',
238 238
 					'type'    => 'gateway_select',
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
 	 * @param  string $return objects or arrays.
258 258
 	 * @return GetPaid_Form_Item[]
259 259
 	 */
260
-	public function get_items( $context = 'view', $return = 'objects' ) {
261
-		$items = $this->get_prop( 'items', $context );
260
+	public function get_items($context = 'view', $return = 'objects') {
261
+		$items = $this->get_prop('items', $context);
262 262
 
263
-		if ( empty( $items ) || ! is_array( $items ) ) {
264
-            $items = wpinv_get_data( 'sample-payment-form-items' );
263
+		if (empty($items) || !is_array($items)) {
264
+            $items = wpinv_get_data('sample-payment-form-items');
265 265
 		}
266 266
 
267 267
 		// Convert the items.
268 268
 		$prepared = array();
269 269
 
270
-		foreach ( $items as $key => $value ) {
270
+		foreach ($items as $key => $value) {
271 271
 
272 272
 			// Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
273
+			if ($value instanceof GetPaid_Form_Item) {
274 274
 
275
-				if ( $value->can_purchase() ) {
275
+				if ($value->can_purchase()) {
276 276
 					$prepared[] = $value;
277 277
 				}
278 278
 
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			// $item_id => $quantity (buy buttons)
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
284
+			if (is_numeric($key) && is_numeric($value)) {
285
+				$item = new GetPaid_Form_Item($key);
286 286
 
287
-				if ( $item->can_purchase() ) {
287
+				if ($item->can_purchase()) {
288 288
 
289 289
 					$value = (float) $value;
290
-					$item->set_quantity( $value );
291
-					if ( 0 == $value ) {
292
-						$item->set_quantity( 1 );
293
-						$item->set_allow_quantities( true );
290
+					$item->set_quantity($value);
291
+					if (0 == $value) {
292
+						$item->set_quantity(1);
293
+						$item->set_allow_quantities(true);
294 294
 					}
295 295
 
296 296
 					$prepared[] = $item;
@@ -300,33 +300,33 @@  discard block
 block discarded – undo
300 300
 			}
301 301
 
302 302
 			// Items saved via payment forms editor.
303
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
303
+			if (is_array($value) && isset($value['id'])) {
304 304
 
305
-				$item = new GetPaid_Form_Item( $value['id'] );
305
+				$item = new GetPaid_Form_Item($value['id']);
306 306
 
307
-				if ( ! $item->can_purchase() ) {
307
+				if (!$item->can_purchase()) {
308 308
 					continue;
309 309
 				}
310 310
 
311 311
 				// Sub-total (Cart items).
312
-				if ( isset( $value['subtotal'] ) ) {
313
-					$item->set_price( $value['subtotal'] );
312
+				if (isset($value['subtotal'])) {
313
+					$item->set_price($value['subtotal']);
314 314
 				}
315 315
 
316
-				if ( isset( $value['quantity'] ) ) {
317
-					$item->set_quantity( $value['quantity'] );
316
+				if (isset($value['quantity'])) {
317
+					$item->set_quantity($value['quantity']);
318 318
 				}
319 319
 
320
-				if ( isset( $value['allow_quantities'] ) ) {
321
-					$item->set_allow_quantities( $value['allow_quantities'] );
320
+				if (isset($value['allow_quantities'])) {
321
+					$item->set_allow_quantities($value['allow_quantities']);
322 322
 				}
323 323
 
324
-				if ( isset( $value['required'] ) ) {
325
-					$item->set_is_required( $value['required'] );
324
+				if (isset($value['required'])) {
325
+					$item->set_is_required($value['required']);
326 326
 				}
327 327
 
328
-				if ( isset( $value['description'] ) ) {
329
-					$item->set_custom_description( $value['description'] );
328
+				if (isset($value['description'])) {
329
+					$item->set_custom_description($value['description']);
330 330
 				}
331 331
 
332 332
 				$prepared[] = $item;
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
 			}
336 336
 
337 337
 			// $item_id => array( 'price' => 10 ) (item variations)
338
-			if ( is_numeric( $key ) && is_array( $value ) ) {
339
-				$item = new GetPaid_Form_Item( $key );
338
+			if (is_numeric($key) && is_array($value)) {
339
+				$item = new GetPaid_Form_Item($key);
340 340
 
341
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
342
-					$item->set_price( $value['price'] );
341
+				if (isset($value['price']) && $item->user_can_set_their_price()) {
342
+					$item->set_price($value['price']);
343 343
 				}
344 344
 
345
-				if ( $item->can_purchase() ) {
345
+				if ($item->can_purchase()) {
346 346
 					$prepared[] = $item;
347 347
 				}
348 348
 
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 			}
351 351
 }
352 352
 
353
-		if ( 'objects' == $return && 'view' == $context ) {
353
+		if ('objects' == $return && 'view' == $context) {
354 354
 			return $prepared;
355 355
 		}
356 356
 
357 357
 		$items = array();
358
-		foreach ( $prepared as $item ) {
358
+		foreach ($prepared as $item) {
359 359
 			$items[] = $item->prepare_data_for_use();
360 360
 		}
361 361
 
@@ -369,14 +369,14 @@  discard block
 block discarded – undo
369 369
 	 * @param  int $item_id The item id to return.
370 370
 	 * @return GetPaid_Form_Item|bool
371 371
 	 */
372
-	public function get_item( $item_id ) {
372
+	public function get_item($item_id) {
373 373
 
374
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
374
+		if (empty($item_id) || !is_numeric($item_id)) {
375 375
 			return false;
376 376
 		}
377 377
 
378
-		foreach ( $this->get_items() as $item ) {
379
-			if ( $item->get_id() == (int) $item_id ) {
378
+		foreach ($this->get_items() as $item) {
379
+			if ($item->get_id() == (int) $item_id) {
380 380
 				return $item;
381 381
 			}
382 382
 		}
@@ -392,15 +392,15 @@  discard block
 block discarded – undo
392 392
 	 * @param  string $element_type The element type to return.
393 393
 	 * @return array|bool
394 394
 	 */
395
-	public function get_element_type( $element_type ) {
395
+	public function get_element_type($element_type) {
396 396
 
397
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
397
+		if (empty($element_type) || !is_scalar($element_type)) {
398 398
 			return false;
399 399
 		}
400 400
 
401
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
401
+		foreach ($this->get_prop('elements') as $element) {
402 402
 
403
-			if ( $element['type'] === $element_type ) {
403
+			if ($element['type'] === $element_type) {
404 404
 				return $element;
405 405
 			}
406 406
 		}
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 * @param  string $context View or edit context.
417 417
 	 * @return float
418 418
 	 */
419
-	public function get_earned( $context = 'view' ) {
420
-		return $this->get_prop( 'earned', $context );
419
+	public function get_earned($context = 'view') {
420
+		return $this->get_prop('earned', $context);
421 421
 	}
422 422
 
423 423
 	/**
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 	 * @param  string $context View or edit context.
428 428
 	 * @return float
429 429
 	 */
430
-	public function get_refunded( $context = 'view' ) {
431
-		return $this->get_prop( 'refunded', $context );
430
+	public function get_refunded($context = 'view') {
431
+		return $this->get_prop('refunded', $context);
432 432
 	}
433 433
 
434 434
 	/**
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 	 * @param  string $context View or edit context.
439 439
 	 * @return float
440 440
 	 */
441
-	public function get_cancelled( $context = 'view' ) {
442
-		return $this->get_prop( 'cancelled', $context );
441
+	public function get_cancelled($context = 'view') {
442
+		return $this->get_prop('cancelled', $context);
443 443
 	}
444 444
 
445 445
 	/**
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 	 * @param  string $context View or edit context.
450 450
 	 * @return float
451 451
 	 */
452
-	public function get_failed( $context = 'view' ) {
453
-		return $this->get_prop( 'failed', $context );
452
+	public function get_failed($context = 'view') {
453
+		return $this->get_prop('failed', $context);
454 454
 	}
455 455
 
456 456
 	/**
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 	 * @return string
462 462
 	 */
463 463
 	public function get_currency() {
464
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
465
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
464
+		$currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency();
465
+		return apply_filters('getpaid-payment-form-currency', $currency, $this);
466 466
 	}
467 467
 
468 468
     /*
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @since 1.0.19
482 482
 	 */
483
-	public function set_version( $value ) {
484
-		$this->set_prop( 'version', $value );
483
+	public function set_version($value) {
484
+		$this->set_prop('version', $value);
485 485
     }
486 486
 
487 487
     /**
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 	 * @param string $value Value to set.
492 492
      * @return bool Whether or not the date was set.
493 493
 	 */
494
-	public function set_date_created( $value ) {
495
-        $date = strtotime( $value );
494
+	public function set_date_created($value) {
495
+        $date = strtotime($value);
496 496
 
497
-        if ( $date ) {
498
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
497
+        if ($date) {
498
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
499 499
             return true;
500 500
         }
501 501
 
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 	 * @param string $value Value to set.
511 511
      * @return bool Whether or not the date was set.
512 512
 	 */
513
-	public function set_date_modified( $value ) {
514
-        $date = strtotime( $value );
513
+	public function set_date_modified($value) {
514
+        $date = strtotime($value);
515 515
 
516
-        if ( $date ) {
517
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
516
+        if ($date) {
517
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
518 518
             return true;
519 519
         }
520 520
 
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 	 * @since 1.0.19
529 529
 	 * @param  string $value New name.
530 530
 	 */
531
-	public function set_name( $value ) {
532
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
531
+	public function set_name($value) {
532
+		$this->set_prop('name', sanitize_text_field($value));
533 533
     }
534 534
 
535 535
     /**
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 	 * @since 1.0.19
539 539
 	 * @param  string $value New name.
540 540
 	 */
541
-	public function set_title( $value ) {
542
-		$this->set_name( $value );
541
+	public function set_title($value) {
542
+		$this->set_name($value);
543 543
     }
544 544
 
545 545
     /**
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 	 * @since 1.0.19
549 549
 	 * @param  int $value New author.
550 550
 	 */
551
-	public function set_author( $value ) {
552
-		$this->set_prop( 'author', (int) $value );
551
+	public function set_author($value) {
552
+		$this->set_prop('author', (int) $value);
553 553
 	}
554 554
 
555 555
 	/**
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 	 * @sinve 2.3.4 Array values sanitized.
560 560
 	 * @param  array $value Form elements.
561 561
 	 */
562
-	public function set_elements( $value ) {
563
-		if ( is_array( $value ) ) {
564
-			$this->set_prop( 'elements', wp_kses_post_deep( $value ) );
562
+	public function set_elements($value) {
563
+		if (is_array($value)) {
564
+			$this->set_prop('elements', wp_kses_post_deep($value));
565 565
 		}
566 566
 	}
567 567
 
@@ -572,36 +572,36 @@  discard block
 block discarded – undo
572 572
 	 *
573 573
 	 * @return mixed
574 574
 	 */
575
-	public function sanitize_array_values( $value ) {
575
+	public function sanitize_array_values($value) {
576 576
 
577 577
 		// sanitize
578
-		if ( ! empty( $value ) ) {
578
+		if (!empty($value)) {
579 579
 
580
-			foreach ( $value as $key => $val_arr ) {
580
+			foreach ($value as $key => $val_arr) {
581 581
 
582
-				if ( is_array( $val_arr ) ) {
582
+				if (is_array($val_arr)) {
583 583
 					// check if we have sub array items.
584 584
 					$sub_arr = array();
585
-					foreach ( $val_arr as $key2 => $val2 ) {
586
-						if ( is_array( $val2 ) ) {
587
-							$sub_arr[ $key2 ] = $this->sanitize_array_values( $val2 );
588
-							unset( $val_arr[ $key ][ $key2 ] );
585
+					foreach ($val_arr as $key2 => $val2) {
586
+						if (is_array($val2)) {
587
+							$sub_arr[$key2] = $this->sanitize_array_values($val2);
588
+							unset($val_arr[$key][$key2]);
589 589
 						}
590 590
 					}
591 591
 
592 592
 					// we allow some html in description so we sanitize it separately.
593
-					$help_text = ! empty( $val_arr['description'] ) ? wp_kses_post( $val_arr['description'] ) : '';
593
+					$help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : '';
594 594
 
595 595
 					// sanitize array elements
596
-					$value[ $key ] = array_map( 'sanitize_text_field', $val_arr );
596
+					$value[$key] = array_map('sanitize_text_field', $val_arr);
597 597
 
598 598
 					// add back the description if set
599
-					if ( isset( $val_arr['description'] ) ) {
600
-$value[ $key ]['description'] = $help_text;}
599
+					if (isset($val_arr['description'])) {
600
+$value[$key]['description'] = $help_text; }
601 601
 
602 602
 					// add back sub array items after its been sanitized.
603
-					if ( ! empty( $sub_arr ) ) {
604
-						$value[ $key ] = array_merge( $value[ $key ], $sub_arr );
603
+					if (!empty($sub_arr)) {
604
+						$value[$key] = array_merge($value[$key], $sub_arr);
605 605
 					}
606 606
 				}
607 607
 }
@@ -616,9 +616,9 @@  discard block
 block discarded – undo
616 616
 	 * @since 1.0.19
617 617
 	 * @param  array $value Form elements.
618 618
 	 */
619
-	public function set_items( $value ) {
620
-		if ( is_array( $value ) ) {
621
-			$this->set_prop( 'items', $value );
619
+	public function set_items($value) {
620
+		if (is_array($value)) {
621
+			$this->set_prop('items', $value);
622 622
 		}
623 623
 	}
624 624
 
@@ -628,9 +628,9 @@  discard block
 block discarded – undo
628 628
 	 * @since 1.0.19
629 629
 	 * @param  float $value Amount earned.
630 630
 	 */
631
-	public function set_earned( $value ) {
632
-		$value = max( (float) $value, 0 );
633
-		$this->set_prop( 'earned', $value );
631
+	public function set_earned($value) {
632
+		$value = max((float) $value, 0);
633
+		$this->set_prop('earned', $value);
634 634
 	}
635 635
 
636 636
 	/**
@@ -639,9 +639,9 @@  discard block
 block discarded – undo
639 639
 	 * @since 1.0.19
640 640
 	 * @param  float $value Amount refunded.
641 641
 	 */
642
-	public function set_refunded( $value ) {
643
-		$value = max( (float) $value, 0 );
644
-		$this->set_prop( 'refunded', $value );
642
+	public function set_refunded($value) {
643
+		$value = max((float) $value, 0);
644
+		$this->set_prop('refunded', $value);
645 645
 	}
646 646
 
647 647
 	/**
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
 	 * @since 1.0.19
651 651
 	 * @param  float $value Amount cancelled.
652 652
 	 */
653
-	public function set_cancelled( $value ) {
654
-		$value = max( (float) $value, 0 );
655
-		$this->set_prop( 'cancelled', $value );
653
+	public function set_cancelled($value) {
654
+		$value = max((float) $value, 0);
655
+		$this->set_prop('cancelled', $value);
656 656
 	}
657 657
 
658 658
 	/**
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
 	 * @since 1.0.19
662 662
 	 * @param  float $value Amount cancelled.
663 663
 	 */
664
-	public function set_failed( $value ) {
665
-		$value = max( (float) $value, 0 );
666
-		$this->set_prop( 'failed', $value );
664
+	public function set_failed($value) {
665
+		$value = max((float) $value, 0);
666
+		$this->set_prop('failed', $value);
667 667
 	}
668 668
 
669 669
     /**
@@ -672,11 +672,11 @@  discard block
 block discarded – undo
672 672
      * @deprecated
673 673
 	 * @return int item id
674 674
      */
675
-    public function create( $data = array() ) {
675
+    public function create($data = array()) {
676 676
 
677 677
 		// Set the properties.
678
-		if ( is_array( $data ) ) {
679
-			$this->set_props( $data );
678
+		if (is_array($data)) {
679
+			$this->set_props($data);
680 680
 		}
681 681
 
682 682
 		// Save the item.
@@ -690,8 +690,8 @@  discard block
 block discarded – undo
690 690
      * @deprecated
691 691
 	 * @return int item id
692 692
      */
693
-    public function update( $data = array() ) {
694
-        return $this->create( $data );
693
+    public function update($data = array()) {
694
+        return $this->create($data);
695 695
     }
696 696
 
697 697
     /*
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	 */
712 712
     public function is_default() {
713 713
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
714
-        return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
714
+        return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this);
715 715
 	}
716 716
 
717 717
     /**
@@ -723,11 +723,11 @@  discard block
 block discarded – undo
723 723
     public function is_active() {
724 724
         $is_active = 0 !== (int) $this->get_id();
725 725
 
726
-        if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) {
726
+        if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') {
727 727
             $is_active = false;
728 728
         }
729 729
 
730
-        return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
730
+        return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this);
731 731
 	}
732 732
 
733 733
 	/**
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 	 * @since 1.0.19
737 737
 	 * @return bool
738 738
 	 */
739
-    public function has_item( $item_id ) {
740
-        return false !== $this->get_item( $item_id );
739
+    public function has_item($item_id) {
740
+        return false !== $this->get_item($item_id);
741 741
 	}
742 742
 
743 743
 	/**
@@ -746,8 +746,8 @@  discard block
 block discarded – undo
746 746
 	 * @since 1.0.19
747 747
 	 * @return bool
748 748
 	 */
749
-    public function has_element_type( $element_type ) {
750
-        return false !== $this->get_element_type( $element_type );
749
+    public function has_element_type($element_type) {
750
+        return false !== $this->get_element_type($element_type);
751 751
 	}
752 752
 
753 753
 	/**
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
 	 */
759 759
     public function is_recurring() {
760 760
 
761
-		if ( ! empty( $this->invoice ) ) {
761
+		if (!empty($this->invoice)) {
762 762
 			return $this->invoice->is_recurring();
763 763
 		}
764 764
 
765
-		foreach ( $this->get_items() as $item ) {
765
+		foreach ($this->get_items() as $item) {
766 766
 
767
-			if ( $item->is_recurring() ) {
767
+			if ($item->is_recurring()) {
768 768
 				return true;
769 769
 			}
770 770
 }
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	 *
778 778
 	 * @since 1.0.19
779 779
 	 */
780
-    public function get_html( $extra_markup = '' ) {
780
+    public function get_html($extra_markup = '') {
781 781
 
782 782
 		// Return the HTML.
783 783
 		return wpinv_get_template_html(
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 	 *
796 796
 	 * @since 1.0.19
797 797
 	 */
798
-    public function display( $extra_markup = '' ) {
798
+    public function display($extra_markup = '') {
799 799
 		wpinv_get_template(
800 800
 			'payment-forms/form.php',
801 801
 			array(
Please login to merge, or discard this patch.
templates/payment-forms/form.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Standardize IDs.
13 13
 global $rendered_getpaid_forms;
14 14
 
15 15
 // Make sure that the form is active.
16
-if ( ! $form->is_active() ) {
16
+if (!$form->is_active()) {
17 17
     aui()->alert(
18 18
         array(
19 19
             'type'    => 'warning',
20
-            'content' => __( 'This payment form is no longer active', 'invoicing' ),
20
+            'content' => __('This payment form is no longer active', 'invoicing'),
21 21
         ),
22 22
         true
23 23
     );
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 }
26 26
 
27 27
 // Require login to checkout.
28
-if ( wpinv_require_login_to_checkout() && ! get_current_user_id() ) {
28
+if (wpinv_require_login_to_checkout() && !get_current_user_id()) {
29 29
 
30 30
     aui()->alert(
31 31
         array(
32 32
             'type'    => 'danger',
33
-            'content' => __( 'You must be logged in to checkout.', 'invoicing' ),
33
+            'content' => __('You must be logged in to checkout.', 'invoicing'),
34 34
         ),
35 35
         true
36 36
     );
@@ -38,36 +38,36 @@  discard block
 block discarded – undo
38 38
 
39 39
 }
40 40
 
41
-if ( ! is_array( $rendered_getpaid_forms ) ) {
41
+if (!is_array($rendered_getpaid_forms)) {
42 42
     $rendered_getpaid_forms = array();
43 43
 }
44 44
 
45
-$rendered_getpaid_forms[ $form->get_id() ] = isset( $rendered_getpaid_forms[ $form->get_id() ] ) ? $rendered_getpaid_forms[ $form->get_id() ] + 1 : 0;
45
+$rendered_getpaid_forms[$form->get_id()] = isset($rendered_getpaid_forms[$form->get_id()]) ? $rendered_getpaid_forms[$form->get_id()] + 1 : 0;
46 46
 
47 47
 // Fires before displaying a payment form.
48
-do_action( 'getpaid_before_payment_form', $form );
48
+do_action('getpaid_before_payment_form', $form);
49 49
 ?>
50 50
 
51
-<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui position-relative' method='POST' data-key='<?php echo esc_attr( uniqid( 'gpf' ) ); ?>' data-currency='<?php echo esc_attr( empty( $form->invoice ) ? wpinv_get_currency() : $form->invoice->get_currency() ); ?>' novalidate>
51
+<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui position-relative' method='POST' data-key='<?php echo esc_attr(uniqid('gpf')); ?>' data-currency='<?php echo esc_attr(empty($form->invoice) ? wpinv_get_currency() : $form->invoice->get_currency()); ?>' novalidate>
52 52
 
53 53
     <?php
54 54
 
55 55
         // Fires when printing the top of a payment form.
56
-        do_action( 'getpaid_payment_form_top', $form );
56
+        do_action('getpaid_payment_form_top', $form);
57 57
 
58 58
         // And the optional invoice id.
59
-        if ( ! empty( $form->invoice ) ) {
60
-		    getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() );
59
+        if (!empty($form->invoice)) {
60
+		    getpaid_hidden_field('invoice_id', $form->invoice->get_id());
61 61
         }
62 62
 
63 63
         // We also want to include the form id.
64
-        getpaid_hidden_field( 'form_id', $form->get_id() );
64
+        getpaid_hidden_field('form_id', $form->get_id());
65 65
 
66 66
         // And an indication that this is a payment form submission.
67
-        getpaid_hidden_field( 'getpaid_payment_form_submission', '1' );
67
+        getpaid_hidden_field('getpaid_payment_form_submission', '1');
68 68
 
69 69
         // Fires before displaying payment form elements.
70
-        do_action( 'getpaid_payment_form_before_elements', $form );
70
+        do_action('getpaid_payment_form_before_elements', $form);
71 71
 
72 72
         // Display the elements.
73 73
         ?>
@@ -75,17 +75,17 @@  discard block
 block discarded – undo
75 75
             <div class="row">
76 76
                 <?php
77 77
 
78
-                    foreach ( $form->get_elements() as $element ) {
79
-					    if ( isset( $element['type'] ) ) {
80
-                            $grid_class = getpaid_get_form_element_grid_class( $element );
81
-                            do_action( 'getpaid_payment_form_element_before', $element, $form );
82
-                            do_action( "getpaid_payment_form_element_before_{$element['type']}_template", $element, $form );
83
-                            echo "<div class='" . esc_attr( $grid_class ) . "'>";
84
-                            do_action( 'getpaid_payment_form_element', $element, $form );
85
-                            do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form );
78
+                    foreach ($form->get_elements() as $element) {
79
+					    if (isset($element['type'])) {
80
+                            $grid_class = getpaid_get_form_element_grid_class($element);
81
+                            do_action('getpaid_payment_form_element_before', $element, $form);
82
+                            do_action("getpaid_payment_form_element_before_{$element['type']}_template", $element, $form);
83
+                            echo "<div class='" . esc_attr($grid_class) . "'>";
84
+                            do_action('getpaid_payment_form_element', $element, $form);
85
+                            do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form);
86 86
                             echo '</div>';
87
-                            do_action( 'getpaid_payment_form_element_after', $element, $form );
88
-                            do_action( "getpaid_payment_form_element_after_{$element['type']}_template", $element, $form );
87
+                            do_action('getpaid_payment_form_element_after', $element, $form);
88
+                            do_action("getpaid_payment_form_element_after_{$element['type']}_template", $element, $form);
89 89
                         }
90 90
                     }
91 91
 
@@ -95,28 +95,28 @@  discard block
 block discarded – undo
95 95
 
96 96
         <?php
97 97
         // Fires after displaying payment form elements.
98
-        do_action( 'getpaid_payment_form_after_elements', $form );
98
+        do_action('getpaid_payment_form_after_elements', $form);
99 99
 
100 100
         echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>";
101 101
 
102
-        if ( wpinv_current_user_can_manage_invoicing() ) {
102
+        if (wpinv_current_user_can_manage_invoicing()) {
103 103
 
104 104
             edit_post_link(
105
-                __( 'Edit this form.', 'invoicing' ),
105
+                __('Edit this form.', 'invoicing'),
106 106
                 '<small class="form-text text-muted">',
107
-                '&nbsp;' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>',
107
+                '&nbsp;' . __('This is only visible to website administators.', 'invoicing') . '</small>',
108 108
                 $form->get_id(),
109 109
                 'text-danger'
110 110
             );
111 111
 
112 112
         }
113 113
 
114
-        echo wp_kses( $extra_markup, getpaid_allowed_html() );
114
+        echo wp_kses($extra_markup, getpaid_allowed_html());
115 115
     ?>
116 116
 
117 117
     <div class="loading_div overlay overlay-black position-absolute row m-0 rounded overflow-hidden" style="height: 100%;width: 100%;top: 0px;z-index: 2;display:none;">
118 118
         <div class="spinner-border mx-auto align-self-center text-white" role="status">
119
-            <span class="sr-only"><?php esc_html_e( 'Loading...', 'invoicing' ); ?></span>
119
+            <span class="sr-only"><?php esc_html_e('Loading...', 'invoicing'); ?></span>
120 120
         </div>
121 121
     </div>
122 122
 
@@ -125,4 +125,4 @@  discard block
 block discarded – undo
125 125
 <?php
126 126
 
127 127
 // Fires after displaying a payment form.
128
-do_action( 'getpaid_after_payment_form', $form );
128
+do_action('getpaid_after_payment_form', $form);
Please login to merge, or discard this patch.