Passed
Push — develop ( 880e1e...04c4f1 )
by Remco
09:23 queued 05:16
created
classes/Payments/PaymentsDataStoreCPT.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -34,36 +34,36 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @return bool
36 36
 	 */
37
-	public function create( Payment $payment ) {
37
+	public function create(Payment $payment) {
38 38
 		$title = $payment->title;
39 39
 
40
-		if ( empty( $title ) ) {
40
+		if (empty($title)) {
41 41
 			$title = sprintf(
42 42
 				'Payment – %s',
43
-				date_i18n( _x( '@todo', 'Payment title date format parsed by `date_i18n`.', 'pronamic_ideal' ) )
43
+				date_i18n(_x('@todo', 'Payment title date format parsed by `date_i18n`.', 'pronamic_ideal'))
44 44
 			);
45 45
 		}
46 46
 
47 47
 		$result = wp_insert_post(
48 48
 			array(
49 49
 				'post_type'     => 'pronamic_payment',
50
-				'post_date_gmt' => $payment->date->format( 'Y-m-d H:i:s' ),
50
+				'post_date_gmt' => $payment->date->format('Y-m-d H:i:s'),
51 51
 				'post_title'    => $title,
52
-				'post_status'   => $this->get_post_status( $payment ),
52
+				'post_status'   => $this->get_post_status($payment),
53 53
 				'post_author'   => $payment->user_id,
54 54
 			), true
55 55
 		);
56 56
 
57
-		if ( is_wp_error( $result ) ) {
57
+		if (is_wp_error($result)) {
58 58
 			return false;
59 59
 		}
60 60
 
61
-		$payment->set_id( $result );
62
-		$payment->post = get_post( $result );
61
+		$payment->set_id($result);
62
+		$payment->post = get_post($result);
63 63
 
64
-		$this->update_post_meta( $payment );
64
+		$this->update_post_meta($payment);
65 65
 
66
-		do_action( 'pronamic_pay_new_payment', $payment );
66
+		do_action('pronamic_pay_new_payment', $payment);
67 67
 
68 68
 		return true;
69 69
 	}
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param Payment $payment The payment to read from this data store.
81 81
 	 */
82
-	public function read( Payment $payment ) {
83
-		$payment->post    = get_post( $payment->get_id() );
84
-		$payment->title   = get_the_title( $payment->get_id() );
85
-		$payment->date    = new \DateTime( get_post_field( 'post_date_gmt', $payment->get_id(), 'raw' ) );
86
-		$payment->user_id = get_post_field( 'post_author', $payment->get_id(), 'raw' );
82
+	public function read(Payment $payment) {
83
+		$payment->post    = get_post($payment->get_id());
84
+		$payment->title   = get_the_title($payment->get_id());
85
+		$payment->date    = new \DateTime(get_post_field('post_date_gmt', $payment->get_id(), 'raw'));
86
+		$payment->user_id = get_post_field('post_author', $payment->get_id(), 'raw');
87 87
 
88
-		$this->read_post_meta( $payment );
88
+		$this->read_post_meta($payment);
89 89
 	}
90 90
 
91 91
 	/**
@@ -95,20 +95,20 @@  discard block
 block discarded – undo
95 95
 	 * @see https://github.com/woocommerce/woocommerce/blob/3.2.6/includes/data-stores/class-wc-order-data-store-cpt.php#L154-L257
96 96
 	 * @param Payment $payment The payment to update in this data store.
97 97
 	 */
98
-	public function update( Payment $payment ) {
98
+	public function update(Payment $payment) {
99 99
 		$data = array(
100 100
 			'ID' => $payment->get_id(),
101 101
 		);
102 102
 
103
-		$post_status = $this->get_post_status( $payment, null );
103
+		$post_status = $this->get_post_status($payment, null);
104 104
 
105
-		if ( null !== $post_status ) {
105
+		if (null !== $post_status) {
106 106
 			$data['post_status'] = $post_status;
107 107
 		}
108 108
 
109
-		wp_update_post( $data );
109
+		wp_update_post($data);
110 110
 
111
-		$this->update_post_meta( $payment );
111
+		$this->update_post_meta($payment);
112 112
 	}
113 113
 
114 114
 	/**
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return string
121 121
 	 */
122
-	private function get_post_status( $payment, $default = 'payment_pending' ) {
123
-		switch ( $payment->status ) {
122
+	private function get_post_status($payment, $default = 'payment_pending') {
123
+		switch ($payment->status) {
124 124
 			case Statuses::CANCELLED:
125 125
 				return 'payment_cancelled';
126 126
 			case Statuses::EXPIRED:
@@ -142,58 +142,58 @@  discard block
 block discarded – undo
142 142
 	 * @see https://github.com/woocommerce/woocommerce/blob/3.2.6/includes/abstracts/abstract-wc-data.php#L462-L507
143 143
 	 * @param Payment $payment The payment to read.
144 144
 	 */
145
-	private function read_post_meta( $payment ) {
145
+	private function read_post_meta($payment) {
146 146
 		$prefix = '_pronamic_payment_';
147 147
 
148 148
 		$id = $payment->get_id();
149 149
 
150
-		$payment->config_id = get_post_meta( $id, $prefix . 'config_id', true );
151
-		$payment->key       = get_post_meta( $id, $prefix . 'key', true );
150
+		$payment->config_id = get_post_meta($id, $prefix . 'config_id', true);
151
+		$payment->key       = get_post_meta($id, $prefix . 'key', true);
152 152
 
153
-		$payment->amount   = (float) get_post_meta( $id, $prefix . 'amount', true );
154
-		$payment->currency = get_post_meta( $id, $prefix . 'currency', true );
155
-		$payment->method   = get_post_meta( $id, $prefix . 'method', true );
156
-		$payment->issuer   = get_post_meta( $id, $prefix . 'issuer', true );
153
+		$payment->amount   = (float) get_post_meta($id, $prefix . 'amount', true);
154
+		$payment->currency = get_post_meta($id, $prefix . 'currency', true);
155
+		$payment->method   = get_post_meta($id, $prefix . 'method', true);
156
+		$payment->issuer   = get_post_meta($id, $prefix . 'issuer', true);
157 157
 
158
-		$payment->order_id       = get_post_meta( $id, $prefix . 'order_id', true );
159
-		$payment->transaction_id = get_post_meta( $id, $prefix . 'transaction_id', true );
160
-		$payment->entrance_code  = get_post_meta( $id, $prefix . 'entrance_code', true );
161
-		$payment->action_url     = get_post_meta( $id, $prefix . 'action_url', true );
158
+		$payment->order_id       = get_post_meta($id, $prefix . 'order_id', true);
159
+		$payment->transaction_id = get_post_meta($id, $prefix . 'transaction_id', true);
160
+		$payment->entrance_code  = get_post_meta($id, $prefix . 'entrance_code', true);
161
+		$payment->action_url     = get_post_meta($id, $prefix . 'action_url', true);
162 162
 
163
-		$payment->source      = get_post_meta( $id, $prefix . 'source', true );
164
-		$payment->source_id   = get_post_meta( $id, $prefix . 'source_id', true );
165
-		$payment->description = get_post_meta( $id, $prefix . 'description', true );
163
+		$payment->source      = get_post_meta($id, $prefix . 'source', true);
164
+		$payment->source_id   = get_post_meta($id, $prefix . 'source_id', true);
165
+		$payment->description = get_post_meta($id, $prefix . 'description', true);
166 166
 
167
-		$payment->language = get_post_meta( $id, $prefix . 'language', true );
168
-		$payment->locale   = get_post_meta( $id, $prefix . 'locale', true );
169
-		$payment->email    = get_post_meta( $id, $prefix . 'email', true );
167
+		$payment->language = get_post_meta($id, $prefix . 'language', true);
168
+		$payment->locale   = get_post_meta($id, $prefix . 'locale', true);
169
+		$payment->email    = get_post_meta($id, $prefix . 'email', true);
170 170
 
171
-		$payment->status = get_post_meta( $id, $prefix . 'status', true );
171
+		$payment->status = get_post_meta($id, $prefix . 'status', true);
172 172
 
173
-		$payment->customer_name       = get_post_meta( $id, $prefix . 'customer_name', true );
174
-		$payment->address             = get_post_meta( $id, $prefix . 'address', true );
175
-		$payment->zip                 = get_post_meta( $id, $prefix . 'zip', true );
176
-		$payment->city                = get_post_meta( $id, $prefix . 'city', true );
177
-		$payment->country             = get_post_meta( $id, $prefix . 'country', true );
178
-		$payment->telephone_number    = get_post_meta( $id, $prefix . 'telephone_number', true );
179
-		$payment->analytics_client_id = get_post_meta( $id, $prefix . 'analytics_client_id', true );
173
+		$payment->customer_name       = get_post_meta($id, $prefix . 'customer_name', true);
174
+		$payment->address             = get_post_meta($id, $prefix . 'address', true);
175
+		$payment->zip                 = get_post_meta($id, $prefix . 'zip', true);
176
+		$payment->city                = get_post_meta($id, $prefix . 'city', true);
177
+		$payment->country             = get_post_meta($id, $prefix . 'country', true);
178
+		$payment->telephone_number    = get_post_meta($id, $prefix . 'telephone_number', true);
179
+		$payment->analytics_client_id = get_post_meta($id, $prefix . 'analytics_client_id', true);
180 180
 
181
-		$payment->subscription_id = get_post_meta( $id, $prefix . 'subscription_id', true );
182
-		$payment->recurring_type  = get_post_meta( $id, $prefix . 'recurring_type', true );
183
-		$payment->recurring       = get_post_meta( $id, $prefix . 'recurring', true );
181
+		$payment->subscription_id = get_post_meta($id, $prefix . 'subscription_id', true);
182
+		$payment->recurring_type  = get_post_meta($id, $prefix . 'recurring_type', true);
183
+		$payment->recurring       = get_post_meta($id, $prefix . 'recurring', true);
184 184
 
185 185
 		// Start Date.
186
-		$start_date_string = get_post_meta( $id, $prefix . 'start_date', true );
186
+		$start_date_string = get_post_meta($id, $prefix . 'start_date', true);
187 187
 
188
-		if ( ! empty( $start_date_string ) ) {
189
-			$payment->start_date = date_create( $start_date_string );
188
+		if ( ! empty($start_date_string)) {
189
+			$payment->start_date = date_create($start_date_string);
190 190
 		}
191 191
 
192 192
 		// End Date.
193
-		$end_date_string = get_post_meta( $id, $prefix . 'end_date', true );
193
+		$end_date_string = get_post_meta($id, $prefix . 'end_date', true);
194 194
 
195
-		if ( ! empty( $end_date_string ) ) {
196
-			$payment->end_date = date_create( $end_date_string );
195
+		if ( ! empty($end_date_string)) {
196
+			$payment->end_date = date_create($end_date_string);
197 197
 		}
198 198
 	}
199 199
 
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
 	 * @see https://github.com/woocommerce/woocommerce/blob/3.2.6/includes/data-stores/class-wc-order-data-store-cpt.php#L154-L257
204 204
 	 * @param Payment $payment The payment to update.
205 205
 	 */
206
-	private function update_post_meta( $payment ) {
206
+	private function update_post_meta($payment) {
207 207
 		$prefix = '_pronamic_payment_';
208 208
 
209
-		$previous_status = get_post_meta( $payment->get_id(), '_pronamic_payment_status', true );
210
-		$previous_status = strtolower( $previous_status );
211
-		$previous_status = empty( $previous_status ) ? 'unknown' : $previous_status;
209
+		$previous_status = get_post_meta($payment->get_id(), '_pronamic_payment_status', true);
210
+		$previous_status = strtolower($previous_status);
211
+		$previous_status = empty($previous_status) ? 'unknown' : $previous_status;
212 212
 
213 213
 		$data = array(
214 214
 			'config_id'               => $payment->config_id,
@@ -248,30 +248,30 @@  discard block
 block discarded – undo
248 248
 			'action_url'              => $payment->get_action_url(),
249 249
 		);
250 250
 
251
-		if ( isset( $payment->start_date ) ) {
252
-			$data['start_date'] = $payment->start_date->format( 'Y-m-d H:i:s' );
251
+		if (isset($payment->start_date)) {
252
+			$data['start_date'] = $payment->start_date->format('Y-m-d H:i:s');
253 253
 		}
254 254
 
255
-		if ( isset( $payment->end_date ) ) {
256
-			$data['end_date'] = $payment->end_date->format( 'Y-m-d H:i:s' );
255
+		if (isset($payment->end_date)) {
256
+			$data['end_date'] = $payment->end_date->format('Y-m-d H:i:s');
257 257
 		}
258 258
 
259
-		$data = array_merge( $payment->meta, $data );
259
+		$data = array_merge($payment->meta, $data);
260 260
 
261
-		foreach ( $data as $key => $value ) {
262
-			if ( ! empty( $value ) ) {
261
+		foreach ($data as $key => $value) {
262
+			if ( ! empty($value)) {
263 263
 				$meta_key = $prefix . $key;
264 264
 
265
-				update_post_meta( $payment->get_id(), $meta_key, $value );
265
+				update_post_meta($payment->get_id(), $meta_key, $value);
266 266
 			}
267 267
 		}
268 268
 
269
-		if ( $previous_status !== $payment->status ) {
269
+		if ($previous_status !== $payment->status) {
270 270
 			$can_redirect = false;
271 271
 
272
-			do_action( 'pronamic_payment_status_update_' . $payment->source . '_' . $previous_status . '_to_' . $payment->status, $payment, $can_redirect );
273
-			do_action( 'pronamic_payment_status_update_' . $payment->source, $payment, $can_redirect );
274
-			do_action( 'pronamic_payment_status_update', $payment, $can_redirect );
272
+			do_action('pronamic_payment_status_update_' . $payment->source . '_' . $previous_status . '_to_' . $payment->status, $payment, $can_redirect);
273
+			do_action('pronamic_payment_status_update_' . $payment->source, $payment, $can_redirect);
274
+			do_action('pronamic_payment_status_update', $payment, $can_redirect);
275 275
 		}
276 276
 	}
277 277
 }
Please login to merge, or discard this patch.
classes/Payments/Payment.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -345,15 +345,15 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * @param int $post_id A payment post ID or null.
347 347
 	 */
348
-	public function __construct( $post_id = null ) {
348
+	public function __construct($post_id = null) {
349 349
 		$this->id   = $post_id;
350 350
 		$this->date = new \DateTime();
351 351
 		$this->meta = array();
352 352
 
353
-		if ( null !== $post_id ) {
353
+		if (null !== $post_id) {
354 354
 			global $pronamic_ideal;
355 355
 
356
-			$pronamic_ideal->payments_data_store->read( $this );
356
+			$pronamic_ideal->payments_data_store->read($this);
357 357
 		}
358 358
 	}
359 359
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @param string $id Unique ID.
373 373
 	 */
374
-	public function set_id( $id ) {
374
+	public function set_id($id) {
375 375
 		$this->id = $id;
376 376
 	}
377 377
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @param string $note The note to add.
382 382
 	 */
383
-	public function add_note( $note ) {
383
+	public function add_note($note) {
384 384
 		$commentdata = array(
385 385
 			'comment_post_ID'      => $this->id,
386 386
 			'comment_author'       => 'admin',
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			'comment_approved'     => 1,
394 394
 		);
395 395
 
396
-		$comment_id = wp_insert_comment( $commentdata );
396
+		$comment_id = wp_insert_comment($commentdata);
397 397
 
398 398
 		return $comment_id;
399 399
 	}
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	public function get_source_text() {
425 425
 		$text = $this->get_source() . '<br />' . $this->get_source_id();
426 426
 
427
-		$text = apply_filters( 'pronamic_payment_source_text_' . $this->get_source(), $text, $this );
428
-		$text = apply_filters( 'pronamic_payment_source_text', $text, $this );
427
+		$text = apply_filters('pronamic_payment_source_text_' . $this->get_source(), $text, $this);
428
+		$text = apply_filters('pronamic_payment_source_text', $text, $this);
429 429
 
430 430
 		return $text;
431 431
 	}
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 	 * @return Ambigous <string, NULL>
464 464
 	 */
465 465
 	public function get_currency_numeric_code() {
466
-		return Currency::transform_code_to_number( $this->get_currency() );
466
+		return Currency::transform_code_to_number($this->get_currency());
467 467
 	}
468 468
 
469 469
 	/**
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @param string $transaction_id Transaction ID.
519 519
 	 */
520
-	public function set_transaction_id( $transaction_id ) {
520
+	public function set_transaction_id($transaction_id) {
521 521
 		$this->transaction_id = $transaction_id;
522 522
 	}
523 523
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	 *
546 546
 	 * @param string $status Status.
547 547
 	 */
548
-	public function set_status( $status ) {
548
+	public function set_status($status) {
549 549
 		$this->status = $status;
550 550
 	}
551 551
 
@@ -555,10 +555,10 @@  discard block
 block discarded – undo
555 555
 	 * @param string $key Meta key.
556 556
 	 * @return mixed
557 557
 	 */
558
-	public function get_meta( $key ) {
558
+	public function get_meta($key) {
559 559
 		$key = '_pronamic_payment_' . $key;
560 560
 
561
-		return get_post_meta( $this->id, $key, true );
561
+		return get_post_meta($this->id, $key, true);
562 562
 	}
563 563
 
564 564
 	/**
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 	 * @param string $key   Meta key.
568 568
 	 * @param string $value Meta value.
569 569
 	 */
570
-	public function set_meta( $key, $value ) {
571
-		$this->meta[ $key ] = $value;
570
+	public function set_meta($key, $value) {
571
+		$this->meta[$key] = $value;
572 572
 	}
573 573
 
574 574
 	/**
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	 * @return string
578 578
 	 */
579 579
 	public function get_pay_redirect_url() {
580
-		return add_query_arg( 'payment_redirect', $this->id, home_url( '/' ) );
580
+		return add_query_arg('payment_redirect', $this->id, home_url('/'));
581 581
 	}
582 582
 
583 583
 	/**
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 				'payment' => $this->id,
593 593
 				'key'     => $this->key,
594 594
 			),
595
-			home_url( '/' )
595
+			home_url('/')
596 596
 		);
597 597
 
598 598
 		return $url;
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
 	 * @return string
605 605
 	 */
606 606
 	public function get_action_url() {
607
-		if ( '' === $this->get_amount() || 0.0 === $this->get_amount() ) {
608
-			$this->set_status( Statuses::SUCCESS );
607
+		if ('' === $this->get_amount() || 0.0 === $this->get_amount()) {
608
+			$this->set_status(Statuses::SUCCESS);
609 609
 
610 610
 			return $this->get_return_redirect_url();
611 611
 		}
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	 *
619 619
 	 * @param string $action_url Action URL.
620 620
 	 */
621
-	public function set_action_url( $action_url ) {
621
+	public function set_action_url($action_url) {
622 622
 		$this->action_url = $action_url;
623 623
 	}
624 624
 
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
 	 * @return string
631 631
 	 */
632 632
 	public function get_return_redirect_url() {
633
-		$url = home_url( '/' );
633
+		$url = home_url('/');
634 634
 
635
-		$url = apply_filters( 'pronamic_payment_redirect_url', $url, $this );
636
-		$url = apply_filters( 'pronamic_payment_redirect_url_' . $this->source, $url, $this );
635
+		$url = apply_filters('pronamic_payment_redirect_url', $url, $this);
636
+		$url = apply_filters('pronamic_payment_redirect_url_' . $this->source, $url, $this);
637 637
 
638 638
 		return $url;
639 639
 	}
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 	 * @return string
646 646
 	 */
647 647
 	public function get_redirect_url() {
648
-		_deprecated_function( __FUNCTION__, '4.1.2', 'get_return_redirect_url()' );
648
+		_deprecated_function(__FUNCTION__, '4.1.2', 'get_return_redirect_url()');
649 649
 
650 650
 		return $this->get_return_redirect_url();
651 651
 	}
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
 	public function get_source_description() {
659 659
 		$description = $this->source;
660 660
 
661
-		$description = apply_filters( 'pronamic_payment_source_description', $description, $this );
662
-		$description = apply_filters( 'pronamic_payment_source_description_' . $this->source, $description, $this );
661
+		$description = apply_filters('pronamic_payment_source_description', $description, $this);
662
+		$description = apply_filters('pronamic_payment_source_description_' . $this->source, $description, $this);
663 663
 
664 664
 		return $description;
665 665
 	}
@@ -672,8 +672,8 @@  discard block
 block discarded – undo
672 672
 	public function get_source_link() {
673 673
 		$url = null;
674 674
 
675
-		$url = apply_filters( 'pronamic_payment_source_url', $url, $this );
676
-		$url = apply_filters( 'pronamic_payment_source_url_' . $this->source, $url, $this );
675
+		$url = apply_filters('pronamic_payment_source_url', $url, $this);
676
+		$url = apply_filters('pronamic_payment_source_url_' . $this->source, $url, $this);
677 677
 
678 678
 		return $url;
679 679
 	}
@@ -686,11 +686,11 @@  discard block
 block discarded – undo
686 686
 	public function get_provider_link() {
687 687
 		$url = null;
688 688
 
689
-		$config_id  = get_post_meta( $this->id, '_pronamic_payment_config_id', true );
690
-		$gateway_id = get_post_meta( $config_id, '_pronamic_gateway_id', true );
689
+		$config_id  = get_post_meta($this->id, '_pronamic_payment_config_id', true);
690
+		$gateway_id = get_post_meta($config_id, '_pronamic_gateway_id', true);
691 691
 
692
-		$url = apply_filters( 'pronamic_payment_provider_url', $url, $this );
693
-		$url = apply_filters( 'pronamic_payment_provider_url_' . $gateway_id, $url, $this );
692
+		$url = apply_filters('pronamic_payment_provider_url', $url, $this);
693
+		$url = apply_filters('pronamic_payment_provider_url_' . $gateway_id, $url, $this);
694 694
 
695 695
 		return $url;
696 696
 	}
@@ -701,15 +701,15 @@  discard block
 block discarded – undo
701 701
 	 * @return Subscription
702 702
 	 */
703 703
 	public function get_subscription() {
704
-		if ( is_object( $this->subscription ) ) {
704
+		if (is_object($this->subscription)) {
705 705
 			return $this->subscription;
706 706
 		}
707 707
 
708
-		if ( empty( $this->subscription_id ) ) {
708
+		if (empty($this->subscription_id)) {
709 709
 			return false;
710 710
 		}
711 711
 
712
-		$this->subscription = new Subscription( $this->subscription_id );
712
+		$this->subscription = new Subscription($this->subscription_id);
713 713
 
714 714
 		return $this->subscription;
715 715
 	}
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 	 * @param string $string The string to format.
723 723
 	 * @return string
724 724
 	 */
725
-	public function format_string( $string ) {
725
+	public function format_string($string) {
726 726
 		// Replacements definition.
727 727
 		$replacements = array(
728 728
 			'{order_id}'   => $this->get_order_id(),
@@ -731,15 +731,15 @@  discard block
 block discarded – undo
731 731
 
732 732
 		// Find and replace.
733 733
 		$string = str_replace(
734
-			array_keys( $replacements ),
735
-			array_values( $replacements ),
734
+			array_keys($replacements),
735
+			array_values($replacements),
736 736
 			$string,
737 737
 			$count
738 738
 		);
739 739
 
740 740
 		// Make sure there is an dynamic part in the order ID.
741 741
 		// @see https://secure.ogone.com/ncol/param_cookbook.asp.
742
-		if ( 0 === $count ) {
742
+		if (0 === $count) {
743 743
 			$string .= $this->get_id();
744 744
 		}
745 745
 
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 	 *
752 752
 	 * @param string $name Name.
753 753
 	 */
754
-	public function set_consumer_name( $name ) {
754
+	public function set_consumer_name($name) {
755 755
 		$this->consumer_name = $name;
756 756
 	}
757 757
 
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 	 *
761 761
 	 * @param string $account_number Account number.
762 762
 	 */
763
-	public function set_consumer_account_number( $account_number ) {
763
+	public function set_consumer_account_number($account_number) {
764 764
 		$this->consumer_account_number = $account_number;
765 765
 	}
766 766
 
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	 *
770 770
 	 * @param string $iban IBAN.
771 771
 	 */
772
-	public function set_consumer_iban( $iban ) {
772
+	public function set_consumer_iban($iban) {
773 773
 		$this->consumer_iban = $iban;
774 774
 	}
775 775
 
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 	 *
779 779
 	 * @param string $bic BIC.
780 780
 	 */
781
-	public function set_consumer_bic( $bic ) {
781
+	public function set_consumer_bic($bic) {
782 782
 		$this->consumer_bic = $bic;
783 783
 	}
784 784
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	 *
788 788
 	 * @param string $city City.
789 789
 	 */
790
-	public function set_consumer_city( $city ) {
790
+	public function set_consumer_city($city) {
791 791
 		$this->consumer_city = $city;
792 792
 	}
793 793
 
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 	 *
896 896
 	 * @param CreditCard $credit_card Credit Card.
897 897
 	 */
898
-	public function set_credit_card( $credit_card ) {
898
+	public function set_credit_card($credit_card) {
899 899
 		$this->credit_card = $credit_card;
900 900
 	}
901 901
 
Please login to merge, or discard this patch.
classes/Payments/StatusChecker.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function __construct() {
31 31
 		// The 'pronamic_ideal_check_transaction_status' hook is scheduled to request the payment status.
32
-		add_action( 'pronamic_ideal_check_transaction_status', array( $this, 'check_status' ), 10, 3 );
32
+		add_action('pronamic_ideal_check_transaction_status', array($this, 'check_status'), 10, 3);
33 33
 	}
34 34
 
35 35
 	/**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param Payment $payment The payment to schedule the status check event.
39 39
 	 */
40
-	public static function schedule_event( $payment ) {
40
+	public static function schedule_event($payment) {
41 41
 		/*
42 42
 		 * Schedule status requests
43 43
 		 * http://pronamic.nl/wp-content/uploads/2011/12/iDEAL_Advanced_PHP_EN_V2.2.pdf (page 19)
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return int
79 79
 	 */
80
-	private function get_delay_seconds( $number_tries ) {
81
-		switch ( $number_tries ) {
80
+	private function get_delay_seconds($number_tries) {
81
+		switch ($number_tries) {
82 82
 			case 0:
83 83
 				// 15 minutes after a transaction request is sent.
84 84
 				return 15 * MINUTE_IN_SECONDS;
@@ -103,29 +103,29 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @internal param string $paymentId
105 105
 	 */
106
-	public function check_status( $payment_id = null, $seconds = null, $number_tries = 1 ) {
107
-		$payment = new Payment( $payment_id );
106
+	public function check_status($payment_id = null, $seconds = null, $number_tries = 1) {
107
+		$payment = new Payment($payment_id);
108 108
 
109 109
 		// Empty payment.
110
-		if ( null === $payment ) {
110
+		if (null === $payment) {
111 111
 			// Payment with the specified ID could not be found, can't check the status.
112 112
 			return;
113 113
 		}
114 114
 
115 115
 		// Limit number tries.
116
-		if ( $number_tries >= 4 ) {
116
+		if ($number_tries >= 4) {
117 117
 			return;
118 118
 		}
119 119
 
120 120
 		// http://pronamic.nl/wp-content/uploads/2011/12/iDEAL_Advanced_PHP_EN_V2.2.pdf (page 19)
121 121
 		// - No status request after a final status has been received for a transaction.
122
-		if ( empty( $payment->status ) || Statuses::OPEN === $payment->status ) {
123
-			Plugin::update_payment( $payment );
122
+		if (empty($payment->status) || Statuses::OPEN === $payment->status) {
123
+			Plugin::update_payment($payment);
124 124
 
125
-			if ( empty( $payment->status ) || Statuses::OPEN === $payment->status ) {
125
+			if (empty($payment->status) || Statuses::OPEN === $payment->status) {
126 126
 				$time = time();
127 127
 
128
-				$seconds = $this->get_delay_seconds( $number_tries );
128
+				$seconds = $this->get_delay_seconds($number_tries);
129 129
 
130 130
 				wp_schedule_single_event(
131 131
 					$time + $seconds, 'pronamic_ideal_check_transaction_status', array(
Please login to merge, or discard this patch.
classes/Payments/PaymentTestData.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @param WP_User $user   A WordPress user.
43 43
 	 * @param float   $amount The amount to test.
44 44
 	 */
45
-	public function __construct( WP_User $user, $amount ) {
45
+	public function __construct(WP_User $user, $amount) {
46 46
 		parent::__construct();
47 47
 
48 48
 		$this->user   = $user;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @return string
67 67
 	 */
68 68
 	public function get_description() {
69
-		return sprintf( __( 'Test %s', 'pronamic_ideal' ), $this->get_order_id() );
69
+		return sprintf(__('Test %s', 'pronamic_ideal'), $this->get_order_id());
70 70
 	}
71 71
 
72 72
 	/**
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 
92 92
 		// Item.
93 93
 		$item = new Item();
94
-		$item->setNumber( $this->get_order_id() );
95
-		$item->setDescription( sprintf( __( 'Test %s', 'pronamic_ideal' ), $this->get_order_id() ) );
96
-		$item->setPrice( $this->amount );
97
-		$item->setQuantity( 1 );
94
+		$item->setNumber($this->get_order_id());
95
+		$item->setDescription(sprintf(__('Test %s', 'pronamic_ideal'), $this->get_order_id()));
96
+		$item->setPrice($this->amount);
97
+		$item->setQuantity(1);
98 98
 
99
-		$items->addItem( $item );
99
+		$items->addItem($item);
100 100
 
101 101
 		return $items;
102 102
 	}
@@ -147,27 +147,27 @@  discard block
 block discarded – undo
147 147
 	 * @return string|bool
148 148
 	 */
149 149
 	public function get_subscription() {
150
-		$test_subscription = filter_input( INPUT_POST, 'pronamic_pay_test_subscription', FILTER_VALIDATE_BOOLEAN );
150
+		$test_subscription = filter_input(INPUT_POST, 'pronamic_pay_test_subscription', FILTER_VALIDATE_BOOLEAN);
151 151
 
152
-		if ( ! $test_subscription ) {
152
+		if ( ! $test_subscription) {
153 153
 			return false;
154 154
 		}
155 155
 
156
-		$times = filter_input( INPUT_POST, 'pronamic_pay_ends_on_count', FILTER_VALIDATE_INT );
156
+		$times = filter_input(INPUT_POST, 'pronamic_pay_ends_on_count', FILTER_VALIDATE_INT);
157 157
 
158
-		if ( empty( $times ) ) {
158
+		if (empty($times)) {
159 159
 			return false;
160 160
 		}
161 161
 
162
-		$interval = filter_input( INPUT_POST, 'pronamic_pay_test_repeat_interval', FILTER_VALIDATE_INT );
162
+		$interval = filter_input(INPUT_POST, 'pronamic_pay_test_repeat_interval', FILTER_VALIDATE_INT);
163 163
 
164
-		if ( empty( $interval ) ) {
164
+		if (empty($interval)) {
165 165
 			return false;
166 166
 		}
167 167
 
168
-		$interval_period = filter_input( INPUT_POST, 'pronamic_pay_test_repeat_frequency', FILTER_SANITIZE_STRING );
168
+		$interval_period = filter_input(INPUT_POST, 'pronamic_pay_test_repeat_frequency', FILTER_SANITIZE_STRING);
169 169
 
170
-		if ( empty( $interval_period ) ) {
170
+		if (empty($interval_period)) {
171 171
 			return false;
172 172
 		}
173 173
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		$subscription->amount          = $this->get_amount();
180 180
 		$subscription->frequency       = $times;
181 181
 		$subscription->interval        = $interval;
182
-		$subscription->interval_period = Core_Util::to_period( $interval_period );
182
+		$subscription->interval_period = Core_Util::to_period($interval_period);
183 183
 
184 184
 		return $subscription;
185 185
 	}
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
 		// $credit_card->set_number( '5555555555554444' );
198 198
 		// $credit_card->set_number( '4111111111111111' );
199 199
 		// $credit_card->set_number( '4000000000000002' );
200
-		$credit_card->set_number( '5300000000000006' );
200
+		$credit_card->set_number('5300000000000006');
201 201
 
202
-		$credit_card->set_expiration_month( 12 );
202
+		$credit_card->set_expiration_month(12);
203 203
 
204
-		$credit_card->set_expiration_year( date( 'Y' ) + 5 );
204
+		$credit_card->set_expiration_year(date('Y') + 5);
205 205
 
206
-		$credit_card->set_security_code( '123' );
206
+		$credit_card->set_security_code('123');
207 207
 
208
-		$credit_card->set_name( 'Pronamic' );
208
+		$credit_card->set_name('Pronamic');
209 209
 
210 210
 		return $credit_card;
211 211
 	}
Please login to merge, or discard this patch.
classes/Payments/Item.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @param string $number Number.
71 71
 	 */
72
-	public function setNumber( $number ) {
72
+	public function setNumber($number) {
73 73
 		$this->number = $number;
74 74
 	}
75 75
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @param string $description Description.
90 90
 	 */
91
-	public function setDescription( $description ) {
92
-		$this->description = substr( $description, 0, 32 );
91
+	public function setDescription($description) {
92
+		$this->description = substr($description, 0, 32);
93 93
 	}
94 94
 
95 95
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param int $quantity Quantity.
108 108
 	 */
109
-	public function setQuantity( $quantity ) {
109
+	public function setQuantity($quantity) {
110 110
 		$this->quantity = $quantity;
111 111
 	}
112 112
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param float $price Price.
126 126
 	 */
127
-	public function setPrice( $price ) {
127
+	public function setPrice($price) {
128 128
 		$this->price = $price;
129 129
 	}
130 130
 
Please login to merge, or discard this patch.
classes/Payments/Items.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @see IteratorAggregate::getIterator()
41 41
 	 */
42 42
 	public function getIterator() {
43
-		return new ArrayIterator( $this->items );
43
+		return new ArrayIterator($this->items);
44 44
 	}
45 45
 
46 46
 	/**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @param Item $item The item to add.
50 50
 	 */
51
-	public function addItem( Item $item ) {
51
+	public function addItem(Item $item) {
52 52
 		$this->items[] = $item;
53 53
 	}
54 54
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	public function get_amount() {
61 61
 		$amount = 0;
62 62
 
63
-		foreach ( $this->items as $item ) {
63
+		foreach ($this->items as $item) {
64 64
 			$amount += $item->get_amount();
65 65
 		}
66 66
 
Please login to merge, or discard this patch.
classes/LicenseManager.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param Plugin $plugin Plugin.
31 31
 	 */
32
-	public function __construct( Plugin $plugin ) {
32
+	public function __construct(Plugin $plugin) {
33 33
 		$this->plugin = $plugin;
34 34
 
35 35
 		// Actions.
36
-		add_action( 'pronamic_pay_license_check', array( $this, 'license_check_event' ) );
37
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
36
+		add_action('pronamic_pay_license_check', array($this, 'license_check_event'));
37
+		add_action('admin_notices', array($this, 'admin_notices'));
38 38
 
39 39
 		// Filters.
40
-		add_filter( sprintf( 'pre_update_option_%s', 'pronamic_pay_license_key' ), array( $this, 'pre_update_option_license_key' ), 10, 2 );
40
+		add_filter(sprintf('pre_update_option_%s', 'pronamic_pay_license_key'), array($this, 'pre_update_option_license_key'), 10, 2);
41 41
 	}
42 42
 
43 43
 	/**
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 	 * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.4.2/includes/class-edd-license-handler.php#L309-L369
48 48
 	 */
49 49
 	public function admin_notices() {
50
-		$data = get_transient( 'pronamic_pay_license_data' );
50
+		$data = get_transient('pronamic_pay_license_data');
51 51
 
52
-		if ( $data ) {
52
+		if ($data) {
53 53
 			include $this->plugin->get_plugin_dir_path() . 'admin/notice-license.php';
54 54
 
55
-			delete_transient( 'pronamic_pay_license_data' );
55
+			delete_transient('pronamic_pay_license_data');
56 56
 		}
57 57
 	}
58 58
 
@@ -63,33 +63,33 @@  discard block
 block discarded – undo
63 63
 	 * @param string $oldvalue Old value.
64 64
 	 * @return string
65 65
 	 */
66
-	public function pre_update_option_license_key( $newvalue, $oldvalue ) {
67
-		$newvalue = trim( $newvalue );
66
+	public function pre_update_option_license_key($newvalue, $oldvalue) {
67
+		$newvalue = trim($newvalue);
68 68
 
69
-		if ( $newvalue !== $oldvalue ) {
70
-			delete_option( 'pronamic_pay_license_status' );
69
+		if ($newvalue !== $oldvalue) {
70
+			delete_option('pronamic_pay_license_status');
71 71
 
72
-			if ( ! empty( $oldvalue ) ) {
73
-				$this->deactivate_license( $oldvalue );
72
+			if ( ! empty($oldvalue)) {
73
+				$this->deactivate_license($oldvalue);
74 74
 			}
75 75
 		}
76 76
 
77
-		delete_transient( 'pronamic_pay_license_data' );
77
+		delete_transient('pronamic_pay_license_data');
78 78
 
79
-		if ( ! empty( $newvalue ) ) {
79
+		if ( ! empty($newvalue)) {
80 80
 			// Always try to activate the new license, it could be deactivated.
81
-			$this->activate_license( $newvalue );
81
+			$this->activate_license($newvalue);
82 82
 		}
83 83
 
84 84
 		// Shedule daily license check.
85 85
 		$time = time() + DAY_IN_SECONDS;
86 86
 
87
-		wp_clear_scheduled_hook( 'pronamic_pay_license_check' );
87
+		wp_clear_scheduled_hook('pronamic_pay_license_check');
88 88
 
89
-		wp_schedule_event( $time, 'daily', 'pronamic_pay_license_check' );
89
+		wp_schedule_event($time, 'daily', 'pronamic_pay_license_check');
90 90
 
91 91
 		// Get and update license status.
92
-		$this->check_license( $newvalue );
92
+		$this->check_license($newvalue);
93 93
 
94 94
 		return $newvalue;
95 95
 	}
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 	 * License check event.
99 99
 	 */
100 100
 	public function license_check_event() {
101
-		$license = get_option( 'pronamic_pay_license_key' );
101
+		$license = get_option('pronamic_pay_license_key');
102 102
 
103
-		$this->check_license( $license );
103
+		$this->check_license($license);
104 104
 	}
105 105
 
106 106
 	/**
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param string $license License.
110 110
 	 */
111
-	public function check_license( $license ) {
111
+	public function check_license($license) {
112 112
 		$status = null;
113 113
 
114
-		if ( empty( $license ) ) {
114
+		if (empty($license)) {
115 115
 			$status = 'invalid';
116 116
 		} else {
117 117
 			// Request.
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 				'url'     => home_url(),
122 122
 			);
123 123
 
124
-			$args = urlencode_deep( $args );
124
+			$args = urlencode_deep($args);
125 125
 
126 126
 			$response = wp_remote_get(
127
-				add_query_arg( $args, 'https://api.pronamic.eu/licenses/check/1.0/' ),
127
+				add_query_arg($args, 'https://api.pronamic.eu/licenses/check/1.0/'),
128 128
 				array(
129 129
 					'timeout' => 20,
130 130
 				)
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 			// On errors we give benefit of the doubt.
134 134
 			$status = 'valid';
135 135
 
136
-			$data = json_decode( wp_remote_retrieve_body( $response ) );
136
+			$data = json_decode(wp_remote_retrieve_body($response));
137 137
 
138
-			if ( $data ) {
138
+			if ($data) {
139 139
 				$status = $data->license;
140 140
 			}
141 141
 		}
142 142
 
143 143
 		// Update.
144
-		update_option( 'pronamic_pay_license_status', $status );
144
+		update_option('pronamic_pay_license_status', $status);
145 145
 	}
146 146
 
147 147
 	/**
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param string $license License to deactivate.
151 151
 	 */
152
-	public function deactivate_license( $license ) {
152
+	public function deactivate_license($license) {
153 153
 		$args = array(
154 154
 			'license' => $license,
155 155
 			'name'    => 'Pronamic iDEAL',
156 156
 			'url'     => home_url(),
157 157
 		);
158 158
 
159
-		$args = urlencode_deep( $args );
159
+		$args = urlencode_deep($args);
160 160
 
161 161
 		$response = wp_remote_get(
162
-			add_query_arg( $args, 'https://api.pronamic.eu/licenses/deactivate/1.0/' ),
162
+			add_query_arg($args, 'https://api.pronamic.eu/licenses/deactivate/1.0/'),
163 163
 			array(
164 164
 				'timeout' => 20,
165 165
 			)
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @param string $license License to activate.
173 173
 	 */
174
-	public function activate_license( $license ) {
174
+	public function activate_license($license) {
175 175
 		// Request.
176 176
 		$args = array(
177 177
 			'license' => $license,
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
 			'url'     => home_url(),
180 180
 		);
181 181
 
182
-		$args = urlencode_deep( $args );
182
+		$args = urlencode_deep($args);
183 183
 
184 184
 		$response = wp_remote_get(
185
-			add_query_arg( $args, 'https://api.pronamic.eu/licenses/activate/1.0/' ),
185
+			add_query_arg($args, 'https://api.pronamic.eu/licenses/activate/1.0/'),
186 186
 			array(
187 187
 				'timeout' => 20,
188 188
 			)
189 189
 		);
190 190
 
191
-		$data = json_decode( wp_remote_retrieve_body( $response ) );
191
+		$data = json_decode(wp_remote_retrieve_body($response));
192 192
 
193
-		if ( $data ) {
194
-			set_transient( 'pronamic_pay_license_data', $data, 30 );
193
+		if ($data) {
194
+			set_transient('pronamic_pay_license_data', $data, 30);
195 195
 		}
196 196
 	}
197 197
 }
Please login to merge, or discard this patch.
classes/Forms/FormShortcode.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param FormsModule $forms_module Reference to the forms module.
25 25
 	 */
26
-	public function __construct( $forms_module ) {
26
+	public function __construct($forms_module) {
27 27
 		$this->forms_module = $forms_module;
28 28
 
29
-		add_shortcode( 'pronamic_payment_form', array( $this, 'shortcode_form' ) );
29
+		add_shortcode('pronamic_payment_form', array($this, 'shortcode_form'));
30 30
 
31
-		add_action( 'init', array( $this, 'shortcode_ui_register' ) );
31
+		add_action('init', array($this, 'shortcode_ui_register'));
32 32
 	}
33 33
 
34 34
 	/**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param array $atts Shortcode attributes array.
40 40
 	 * @return string
41 41
 	 */
42
-	public function shortcode_form( $atts ) {
42
+	public function shortcode_form($atts) {
43 43
 		$atts = shortcode_atts(
44 44
 			array(
45 45
 				'id' => null,
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 
49 49
 		$id = $atts['id'];
50 50
 
51
-		return $this->forms_module->get_form_output( $id );
51
+		return $this->forms_module->get_form_output($id);
52 52
 	}
53 53
 
54 54
 	/**
55 55
 	 * Shortcode user interface register.
56 56
 	 */
57 57
 	public function shortcode_ui_register() {
58
-		if ( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
58
+		if ( ! function_exists('shortcode_ui_register_for_shortcode')) {
59 59
 			return;
60 60
 		}
61 61
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			'pronamic_payment_form',
64 64
 			array(
65 65
 				// Display label. String. Required.
66
-				'label'         => __( 'Payment Form', 'pronamic_ideal' ),
66
+				'label'         => __('Payment Form', 'pronamic_ideal'),
67 67
 
68 68
 				// Icon/attachment for shortcode. Optional. src or dashicons-$icon. Defaults to carrot.
69 69
 				'listItemImage' => 'dashicons-money',
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 				'attrs'         => array(
75 75
 
76 76
 					array(
77
-						'label'    => __( 'Select Payment Form', 'pronamic_ideal' ),
77
+						'label'    => __('Select Payment Form', 'pronamic_ideal'),
78 78
 						'attr'     => 'id',
79 79
 						'type'     => 'post_select',
80 80
 						'query'    => array(
Please login to merge, or discard this patch.
classes/Forms/FormPostType.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -58,21 +58,21 @@  discard block
 block discarded – undo
58 58
 		 *
59 59
 		 * @see https://github.com/WordPress/WordPress/blob/4.0/wp-includes/post.php#L167.
60 60
 		 */
61
-		add_action( 'init', array( $this, 'register_post_type' ), 0 ); // Highest priority.
61
+		add_action('init', array($this, 'register_post_type'), 0); // Highest priority.
62 62
 
63
-		add_filter( 'manage_edit-' . self::POST_TYPE . '_columns', array( $this, 'edit_columns' ) );
63
+		add_filter('manage_edit-' . self::POST_TYPE . '_columns', array($this, 'edit_columns'));
64 64
 
65
-		add_action( 'manage_' . self::POST_TYPE . '_posts_custom_column', array( $this, 'custom_columns' ), 10, 2 );
65
+		add_action('manage_' . self::POST_TYPE . '_posts_custom_column', array($this, 'custom_columns'), 10, 2);
66 66
 
67 67
 		/*
68 68
 		 * Add meta box, we use priority 9 to make sure it loads before Yoast SEO meta box.
69 69
 		 * @see https://github.com/Yoast/wordpress-seo/blob/2.3.4/admin/class-metabox.php#L20.
70 70
 		 */
71
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 9 );
71
+		add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 9);
72 72
 
73
-		add_action( 'save_post_' . self::POST_TYPE, array( $this, 'save_post' ) );
73
+		add_action('save_post_' . self::POST_TYPE, array($this, 'save_post'));
74 74
 
75
-		add_action( 'post_submitbox_misc_actions', array( $this, 'post_submitbox_misc_actions' ) );
75
+		add_action('post_submitbox_misc_actions', array($this, 'post_submitbox_misc_actions'));
76 76
 	}
77 77
 
78 78
 	/**
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	public function register_post_type() {
82 82
 		register_post_type(
83 83
 			self::POST_TYPE, array(
84
-				'label'              => __( 'Payment Forms', 'pronamic_ideal' ),
84
+				'label'              => __('Payment Forms', 'pronamic_ideal'),
85 85
 				'labels'             => array(
86
-					'name'                  => __( 'Payment Forms', 'pronamic_ideal' ),
87
-					'singular_name'         => __( 'Payment Form', 'pronamic_ideal' ),
88
-					'add_new'               => __( 'Add New', 'pronamic_ideal' ),
89
-					'add_new_item'          => __( 'Add New Payment Form', 'pronamic_ideal' ),
90
-					'edit_item'             => __( 'Edit Payment Form', 'pronamic_ideal' ),
91
-					'new_item'              => __( 'New Payment Form', 'pronamic_ideal' ),
92
-					'all_items'             => __( 'All Payment Forms', 'pronamic_ideal' ),
93
-					'view_item'             => __( 'View Payment Form', 'pronamic_ideal' ),
94
-					'search_items'          => __( 'Search Payment Forms', 'pronamic_ideal' ),
95
-					'not_found'             => __( 'No payment forms found.', 'pronamic_ideal' ),
96
-					'not_found_in_trash'    => __( 'No payment forms found in Trash.', 'pronamic_ideal' ),
97
-					'menu_name'             => __( 'Payment Forms', 'pronamic_ideal' ),
98
-					'filter_items_list'     => __( 'Filter payment forms list', 'pronamic_ideal' ),
99
-					'items_list_navigation' => __( 'Payment forms list navigation', 'pronamic_ideal' ),
100
-					'items_list'            => __( 'Payment forms list', 'pronamic_ideal' ),
86
+					'name'                  => __('Payment Forms', 'pronamic_ideal'),
87
+					'singular_name'         => __('Payment Form', 'pronamic_ideal'),
88
+					'add_new'               => __('Add New', 'pronamic_ideal'),
89
+					'add_new_item'          => __('Add New Payment Form', 'pronamic_ideal'),
90
+					'edit_item'             => __('Edit Payment Form', 'pronamic_ideal'),
91
+					'new_item'              => __('New Payment Form', 'pronamic_ideal'),
92
+					'all_items'             => __('All Payment Forms', 'pronamic_ideal'),
93
+					'view_item'             => __('View Payment Form', 'pronamic_ideal'),
94
+					'search_items'          => __('Search Payment Forms', 'pronamic_ideal'),
95
+					'not_found'             => __('No payment forms found.', 'pronamic_ideal'),
96
+					'not_found_in_trash'    => __('No payment forms found in Trash.', 'pronamic_ideal'),
97
+					'menu_name'             => __('Payment Forms', 'pronamic_ideal'),
98
+					'filter_items_list'     => __('Filter payment forms list', 'pronamic_ideal'),
99
+					'items_list_navigation' => __('Payment forms list navigation', 'pronamic_ideal'),
100
+					'items_list'            => __('Payment forms list', 'pronamic_ideal'),
101 101
 				),
102 102
 				'public'             => true,
103 103
 				'publicly_queryable' => true,
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 					'revisions',
111 111
 				),
112 112
 				'rewrite'            => array(
113
-					'slug' => _x( 'payment-forms', 'slug', 'pronamic_ideal' ),
113
+					'slug' => _x('payment-forms', 'slug', 'pronamic_ideal'),
114 114
 				),
115 115
 				'query_var'          => false,
116 116
 				'capabilities'       => FormPostType::get_capabilities(),
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
 	 * @param array $columns Edit columns.
126 126
 	 * @return array
127 127
 	 */
128
-	public function edit_columns( $columns ) {
128
+	public function edit_columns($columns) {
129 129
 		$columns = array(
130 130
 			'cb'                              => '<input type="checkbox" />',
131
-			'title'                           => __( 'Title', 'pronamic_ideal' ),
132
-			'pronamic_payment_form_gateway'   => __( 'Gateway', 'pronamic_ideal' ),
133
-			'pronamic_payment_form_payments'  => __( 'Payments', 'pronamic_ideal' ),
134
-			'pronamic_payment_form_earnings'  => __( 'Earnings', 'pronamic_ideal' ),
135
-			'pronamic_payment_form_shortcode' => __( 'Shortcode', 'pronamic_ideal' ),
136
-			'date'                            => __( 'Date', 'pronamic_ideal' ),
131
+			'title'                           => __('Title', 'pronamic_ideal'),
132
+			'pronamic_payment_form_gateway'   => __('Gateway', 'pronamic_ideal'),
133
+			'pronamic_payment_form_payments'  => __('Payments', 'pronamic_ideal'),
134
+			'pronamic_payment_form_earnings'  => __('Earnings', 'pronamic_ideal'),
135
+			'pronamic_payment_form_shortcode' => __('Shortcode', 'pronamic_ideal'),
136
+			'date'                            => __('Date', 'pronamic_ideal'),
137 137
 		);
138 138
 
139 139
 		return $columns;
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 	 * @param string $column  Column.
146 146
 	 * @param string $post_id Post ID.
147 147
 	 */
148
-	public function custom_columns( $column, $post_id ) {
148
+	public function custom_columns($column, $post_id) {
149 149
 		global $post;
150 150
 
151
-		switch ( $column ) {
151
+		switch ($column) {
152 152
 			case 'pronamic_payment_form_gateway':
153
-				$config_id = get_post_meta( $post_id, '_pronamic_payment_form_config_id', true );
153
+				$config_id = get_post_meta($post_id, '_pronamic_payment_form_config_id', true);
154 154
 
155
-				if ( ! empty( $config_id ) ) {
156
-					echo get_the_title( $config_id );
155
+				if ( ! empty($config_id)) {
156
+					echo get_the_title($config_id);
157 157
 				} else {
158 158
 					echo '—';
159 159
 				}
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 					$post_id
192 192
 				);
193 193
 
194
-				$value = $wpdb->get_var( $query ); // WPCS: unprepared SQL ok.
194
+				$value = $wpdb->get_var($query); // WPCS: unprepared SQL ok.
195 195
 
196
-				echo esc_html( number_format_i18n( $value ) );
196
+				echo esc_html(number_format_i18n($value));
197 197
 
198 198
 				break;
199 199
 			case 'pronamic_payment_form_earnings':
@@ -228,15 +228,15 @@  discard block
 block discarded – undo
228 228
 					$post_id
229 229
 				);
230 230
 
231
-				$value = $wpdb->get_var( $query ); // WPCS: unprepared SQL ok.
231
+				$value = $wpdb->get_var($query); // WPCS: unprepared SQL ok.
232 232
 
233
-				echo esc_html( \Pronamic\WordPress\Pay\Util::format_price( $value ) );
233
+				echo esc_html(\Pronamic\WordPress\Pay\Util::format_price($value));
234 234
 
235 235
 				break;
236 236
 			case 'pronamic_payment_form_shortcode':
237 237
 				printf(
238 238
 					'<input onclick="this.setSelectionRange( 0, this.value.length )" type="text" class="pronamic-pay-shortcode-input" readonly="" value="%s" />',
239
-					esc_attr( $this->get_shortcode( $post_id ) )
239
+					esc_attr($this->get_shortcode($post_id))
240 240
 				);
241 241
 
242 242
 				break;
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @param string $post_type Post Type.
250 250
 	 */
251
-	public function add_meta_boxes( $post_type ) {
252
-		if ( self::POST_TYPE === $post_type ) {
251
+	public function add_meta_boxes($post_type) {
252
+		if (self::POST_TYPE === $post_type) {
253 253
 			add_meta_box(
254 254
 				'pronamic_payment_form_options',
255
-				__( 'Form Options', 'pronamic_ideal' ),
256
-				array( $this, 'meta_box_form_options' ),
255
+				__('Form Options', 'pronamic_ideal'),
256
+				array($this, 'meta_box_form_options'),
257 257
 				$post_type,
258 258
 				'normal',
259 259
 				'high'
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @param WP_Post $post The object for the current post/page.
268 268
 	 */
269
-	public function meta_box_form_options( $post ) {
269
+	public function meta_box_form_options($post) {
270 270
 		include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-form-options.php';
271 271
 	}
272 272
 
@@ -275,21 +275,21 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @param int $post_id The ID of the post being saved.
277 277
 	 */
278
-	public function save_post( $post_id ) {
278
+	public function save_post($post_id) {
279 279
 		// Check if our nonce is set.
280
-		if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_nonce' ) ) {
280
+		if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) {
281 281
 			return $post_id;
282 282
 		}
283 283
 
284
-		$nonce = filter_input( INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING );
284
+		$nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING);
285 285
 
286 286
 		// Verify that the nonce is valid.
287
-		if ( ! wp_verify_nonce( $nonce, 'pronamic_pay_save_form_options' ) ) {
287
+		if ( ! wp_verify_nonce($nonce, 'pronamic_pay_save_form_options')) {
288 288
 			return $post_id;
289 289
 		}
290 290
 
291 291
 		// If this is an autosave, our form has not been submitted, so we don't want to do anything.
292
-		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
292
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
293 293
 			return $post_id;
294 294
 		}
295 295
 
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 			),
305 305
 		);
306 306
 
307
-		$data = filter_input_array( INPUT_POST, $definition );
307
+		$data = filter_input_array(INPUT_POST, $definition);
308 308
 
309 309
 		// Convert amount choices to cents.
310
-		if ( isset( $data['_pronamic_payment_form_amount_choices'] ) ) {
311
-			foreach ( $data['_pronamic_payment_form_amount_choices'] as $i => $amount ) {
312
-				$amount = \Pronamic\WordPress\Pay\Core\Util::string_to_amount( $amount );
310
+		if (isset($data['_pronamic_payment_form_amount_choices'])) {
311
+			foreach ($data['_pronamic_payment_form_amount_choices'] as $i => $amount) {
312
+				$amount = \Pronamic\WordPress\Pay\Core\Util::string_to_amount($amount);
313 313
 
314
-				$data['_pronamic_payment_form_amount_choices'][ $i ] = \Pronamic\WordPress\Pay\Core\Util::amount_to_cents( $amount );
314
+				$data['_pronamic_payment_form_amount_choices'][$i] = \Pronamic\WordPress\Pay\Core\Util::amount_to_cents($amount);
315 315
 			}
316 316
 
317 317
 			// Remove empty choices.
318
-			$data['_pronamic_payment_form_amount_choices'] = array_filter( $data['_pronamic_payment_form_amount_choices'] );
318
+			$data['_pronamic_payment_form_amount_choices'] = array_filter($data['_pronamic_payment_form_amount_choices']);
319 319
 		}
320 320
 
321 321
 		// Update post meta data.
322
-		pronamic_pay_update_post_meta_data( $post_id, $data );
322
+		pronamic_pay_update_post_meta_data($post_id, $data);
323 323
 	}
324 324
 
325 325
 	/**
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
 	 * @param string $post_id Post ID.
329 329
 	 * @return string
330 330
 	 */
331
-	private function get_shortcode( $post_id = null ) {
332
-		$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
331
+	private function get_shortcode($post_id = null) {
332
+		$post_id = (null === $post_id) ? get_the_ID() : $post_id;
333 333
 
334
-		$shortcode = sprintf( '[pronamic_payment_form id="%s"]', esc_attr( $post_id ) );
334
+		$shortcode = sprintf('[pronamic_payment_form id="%s"]', esc_attr($post_id));
335 335
 
336 336
 		return $shortcode;
337 337
 	}
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
 	 * Post submit box miscellaneous actions.
341 341
 	 */
342 342
 	public function post_submitbox_misc_actions() {
343
-		if ( self::POST_TYPE !== get_post_type() ) {
343
+		if (self::POST_TYPE !== get_post_type()) {
344 344
 			return false;
345 345
 		}
346 346
 
347 347
 		?>
348 348
 <div class="misc-pub-section">
349
-	<label for="pronamic-pay-shortcode"><?php esc_html_e( 'Shortcode:', 'pronamic_ideal' ); ?></label>
349
+	<label for="pronamic-pay-shortcode"><?php esc_html_e('Shortcode:', 'pronamic_ideal'); ?></label>
350 350
 
351
-	<input id="pronamic-pay-shortcode" class="pronamic-pay-shortcode-input" onClick="this.setSelectionRange( 0, this.value.length )" type="text" class="shortcode-input" readonly value="<?php echo esc_attr( $this->get_shortcode() ); ?>" />
351
+	<input id="pronamic-pay-shortcode" class="pronamic-pay-shortcode-input" onClick="this.setSelectionRange( 0, this.value.length )" type="text" class="shortcode-input" readonly value="<?php echo esc_attr($this->get_shortcode()); ?>" />
352 352
 </div>
353 353
 <?php
354 354
 	}
Please login to merge, or discard this patch.