Passed
Push — develop ( 9dd1ea...d92e32 )
by Reüel
07:15
created
src/Extension.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function __construct() {
49 49
 		// @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprGatewayFactory.php#L48-50
50
-		add_filter( 'mepr-gateway-paths', array( $this, 'gateway_paths' ) );
50
+		add_filter('mepr-gateway-paths', array($this, 'gateway_paths'));
51 51
 
52
-		add_filter( 'pronamic_payment_redirect_url_' . self::SLUG, array( __CLASS__, 'redirect_url' ), 10, 2 );
53
-		add_action( 'pronamic_payment_status_update_' . self::SLUG, array( __CLASS__, 'status_update' ), 10, 1 );
52
+		add_filter('pronamic_payment_redirect_url_' . self::SLUG, array(__CLASS__, 'redirect_url'), 10, 2);
53
+		add_action('pronamic_payment_status_update_' . self::SLUG, array(__CLASS__, 'status_update'), 10, 1);
54 54
 
55
-		add_filter( 'pronamic_payment_source_text_' . self::SLUG, array( __CLASS__, 'source_text' ), 10, 2 );
56
-		add_filter( 'pronamic_payment_source_description_' . self::SLUG, array( __CLASS__, 'source_description' ), 10, 2 );
57
-		add_filter( 'pronamic_payment_source_url_' . self::SLUG, array( __CLASS__, 'source_url' ), 10, 2 );
58
-		add_filter( 'pronamic_subscription_source_text_' . self::SLUG, array( __CLASS__, 'subscription_source_text' ), 10, 2 );
59
-		add_filter( 'pronamic_subscription_source_description_' . self::SLUG, array( __CLASS__, 'subscription_source_description' ), 10, 2 );
60
-		add_filter( 'pronamic_subscription_source_url_' . self::SLUG, array( __CLASS__, 'subscription_source_url' ), 10, 2 );
55
+		add_filter('pronamic_payment_source_text_' . self::SLUG, array(__CLASS__, 'source_text'), 10, 2);
56
+		add_filter('pronamic_payment_source_description_' . self::SLUG, array(__CLASS__, 'source_description'), 10, 2);
57
+		add_filter('pronamic_payment_source_url_' . self::SLUG, array(__CLASS__, 'source_url'), 10, 2);
58
+		add_filter('pronamic_subscription_source_text_' . self::SLUG, array(__CLASS__, 'subscription_source_text'), 10, 2);
59
+		add_filter('pronamic_subscription_source_description_' . self::SLUG, array(__CLASS__, 'subscription_source_description'), 10, 2);
60
+		add_filter('pronamic_subscription_source_url_' . self::SLUG, array(__CLASS__, 'subscription_source_url'), 10, 2);
61 61
 
62
-		add_action( 'mepr_subscription_pre_delete', array( $this, 'subscription_pre_delete' ), 10, 1 );
62
+		add_action('mepr_subscription_pre_delete', array($this, 'subscription_pre_delete'), 10, 1);
63 63
 
64
-		add_action( 'mepr_subscription_transition_status', array( $this, 'memberpress_subscription_transition_status' ), 10, 3 );
64
+		add_action('mepr_subscription_transition_status', array($this, 'memberpress_subscription_transition_status'), 10, 3);
65 65
 	}
66 66
 
67 67
 	/**
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 * @param array $paths Array with gateway paths.
73 73
 	 * @return array
74 74
 	 */
75
-	public function gateway_paths( $paths ) {
76
-		$paths[] = dirname( __FILE__ ) . '/../gateways/';
75
+	public function gateway_paths($paths) {
76
+		$paths[] = dirname(__FILE__) . '/../gateways/';
77 77
 
78 78
 		return $paths;
79 79
 	}
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return string
90 90
 	 */
91
-	public static function redirect_url( $url, Payment $payment ) {
91
+	public static function redirect_url($url, Payment $payment) {
92 92
 		global $transaction;
93 93
 
94 94
 		$transaction_id = $payment->get_source_id();
95 95
 
96
-		$transaction = new MeprTransaction( $transaction_id );
96
+		$transaction = new MeprTransaction($transaction_id);
97 97
 
98
-		switch ( $payment->get_status() ) {
98
+		switch ($payment->get_status()) {
99 99
 			case Statuses::CANCELLED:
100 100
 			case Statuses::EXPIRED:
101 101
 			case Statuses::FAILURE:
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 						'action'   => 'payment_form',
107 107
 						'txn'      => $transaction->trans_num,
108 108
 						'errors'   => array(
109
-							__( 'Payment failed. Please try again.', 'pronamic_ideal' ),
109
+							__('Payment failed. Please try again.', 'pronamic_ideal'),
110 110
 						),
111
-						'_wpnonce' => wp_create_nonce( 'mepr_payment_form' ),
111
+						'_wpnonce' => wp_create_nonce('mepr_payment_form'),
112 112
 					),
113 113
 					$product->url()
114 114
 				);
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 				// @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L768-782
119 119
 				$mepr_options = MeprOptions::fetch();
120 120
 
121
-				$product         = new MeprProduct( $transaction->product_id );
122
-				$sanitized_title = sanitize_title( $product->post_title );
121
+				$product         = new MeprProduct($transaction->product_id);
122
+				$sanitized_title = sanitize_title($product->post_title);
123 123
 
124 124
 				$args = array(
125 125
 					'membership_id' => $product->ID,
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 					'trans_num'     => $transaction->trans_num,
128 128
 				);
129 129
 
130
-				$url = $mepr_options->thankyou_page_url( http_build_query( $args ) );
130
+				$url = $mepr_options->thankyou_page_url(http_build_query($args));
131 131
 
132 132
 				break;
133 133
 			case Statuses::OPEN:
@@ -145,26 +145,26 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param Payment $payment The payment whose status is updated.
147 147
 	 */
148
-	public static function status_update( Payment $payment ) {
148
+	public static function status_update(Payment $payment) {
149 149
 		$transaction_id = $payment->get_source_id();
150 150
 
151
-		$transaction = new MeprTransaction( $transaction_id );
151
+		$transaction = new MeprTransaction($transaction_id);
152 152
 
153
-		if ( $payment->get_recurring() ) {
153
+		if ($payment->get_recurring()) {
154 154
 			$subscription = $transaction->subscription();
155 155
 
156
-			if ( empty( $subscription ) || empty( $subscription->id ) ) {
156
+			if (empty($subscription) || empty($subscription->id)) {
157 157
 				$subscription_id = $payment->get_subscription()->get_source_id();
158 158
 
159
-				$subscription = new MeprSubscription( $subscription_id );
159
+				$subscription = new MeprSubscription($subscription_id);
160 160
 			}
161 161
 
162 162
 			// Same source ID and first transaction ID for recurring payment means we need to add a new transaction.
163
-			if ( $payment->get_source_id() === $subscription->id ) {
163
+			if ($payment->get_source_id() === $subscription->id) {
164 164
 				// First transaction.
165 165
 				$first_txn = $subscription->first_txn();
166 166
 
167
-				if ( false === $first_txn || ! ( $first_txn instanceof MeprTransaction ) ) {
167
+				if (false === $first_txn || ! ($first_txn instanceof MeprTransaction)) {
168 168
 					$first_txn             = new MeprTransaction();
169 169
 					$first_txn->user_id    = $subscription->user_id;
170 170
 					$first_txn->product_id = $subscription->product_id;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 				// Transaction number.
176 176
 				$trans_num = $payment->get_transaction_id();
177 177
 
178
-				if ( empty( $trans_num ) ) {
178
+				if (empty($trans_num)) {
179 179
 					$trans_num = uniqid();
180 180
 				}
181 181
 
@@ -191,16 +191,16 @@  discard block
 block discarded – undo
191 191
 				$transaction->status          = MeprTransaction::$pending_str;
192 192
 				$transaction->subscription_id = $subscription->id;
193 193
 
194
-				$transaction->set_gross( $payment->get_amount()->get_amount() );
194
+				$transaction->set_gross($payment->get_amount()->get_amount());
195 195
 
196 196
 				$transaction->store();
197 197
 
198 198
 				// Set source ID.
199
-				$payment->set_meta( 'source_id', $transaction->id );
199
+				$payment->set_meta('source_id', $transaction->id);
200 200
 
201 201
 				$payment->source_id = $transaction->id;
202 202
 
203
-				if ( MeprSubscription::$active_str === $subscription->status ) {
203
+				if (MeprSubscription::$active_str === $subscription->status) {
204 204
 					/*
205 205
 					 * We create a 'confirmed' 'subscription_confirmation'
206 206
 					 * transaction for a grace period of 15 days.
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 					$subscription_confirmation->txn_type        = MeprTransaction::$subscription_confirmation_str;
223 223
 					$subscription_confirmation->status          = MeprTransaction::$confirmed_str;
224 224
 					$subscription_confirmation->subscription_id = $subscription->id;
225
-					$subscription_confirmation->expires_at      = MeprUtils::ts_to_mysql_date( strtotime( $payment->post->post_date_gmt ) + MeprUtils::days( 15 ), 'Y-m-d 23:59:59' );
225
+					$subscription_confirmation->expires_at      = MeprUtils::ts_to_mysql_date(strtotime($payment->post->post_date_gmt) + MeprUtils::days(15), 'Y-m-d 23:59:59');
226 226
 
227
-					$subscription_confirmation->set_subtotal( 0.00 );
227
+					$subscription_confirmation->set_subtotal(0.00);
228 228
 
229 229
 					$subscription_confirmation->store();
230 230
 				}
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
 			)
240 240
 		);
241 241
 
242
-		if ( $should_update ) {
242
+		if ($should_update) {
243 243
 			$gateway = new Gateway();
244 244
 
245 245
 			$gateway->mp_txn = $transaction;
246 246
 
247
-			switch ( $payment->get_status() ) {
247
+			switch ($payment->get_status()) {
248 248
 				case Statuses::CANCELLED:
249 249
 				case Statuses::EXPIRED:
250 250
 				case Statuses::FAILURE:
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 					break;
254 254
 				case Statuses::SUCCESS:
255
-					if ( $payment->get_recurring() ) {
255
+					if ($payment->get_recurring()) {
256 256
 						$gateway->record_subscription_payment();
257 257
 					} else {
258 258
 						$gateway->record_payment();
@@ -271,25 +271,25 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @param int $subscription_id MemberPress subscription id.
273 273
 	 */
274
-	public function subscription_pre_delete( $subscription_id ) {
275
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $subscription_id );
274
+	public function subscription_pre_delete($subscription_id) {
275
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $subscription_id);
276 276
 
277
-		if ( ! $subscription ) {
277
+		if ( ! $subscription) {
278 278
 			return;
279 279
 		}
280 280
 
281 281
 		// Add note.
282 282
 		$note = sprintf(
283 283
 			/* translators: %s: MemberPress */
284
-			__( '%s subscription deleted.', 'pronamic_ideal' ),
285
-			__( 'MemberPress', 'pronamic_ideal' )
284
+			__('%s subscription deleted.', 'pronamic_ideal'),
285
+			__('MemberPress', 'pronamic_ideal')
286 286
 		);
287 287
 
288
-		$subscription->add_note( $note );
288
+		$subscription->add_note($note);
289 289
 
290 290
 		// The status of canceled or completed subscriptions will not be changed automatically.
291
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
292
-			$subscription->set_status( Statuses::CANCELLED );
291
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
292
+			$subscription->set_status(Statuses::CANCELLED);
293 293
 
294 294
 			$subscription->save();
295 295
 		}
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @return string
305 305
 	 */
306
-	public static function source_text( $text, Payment $payment ) {
307
-		$text = __( 'MemberPress', 'pronamic_ideal' ) . '<br />';
306
+	public static function source_text($text, Payment $payment) {
307
+		$text = __('MemberPress', 'pronamic_ideal') . '<br />';
308 308
 
309 309
 		$text .= sprintf(
310 310
 			'<a href="%s">%s</a>',
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
 					'action' => 'edit',
315 315
 					'id'     => $payment->source_id,
316 316
 				),
317
-				admin_url( 'admin.php' )
317
+				admin_url('admin.php')
318 318
 			),
319 319
 			/* translators: %s: payment source id */
320
-			sprintf( __( 'Transaction %s', 'pronamic_ideal' ), $payment->source_id )
320
+			sprintf(__('Transaction %s', 'pronamic_ideal'), $payment->source_id)
321 321
 		);
322 322
 
323 323
 		return $text;
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 *
332 332
 	 * @return string
333 333
 	 */
334
-	public static function subscription_source_text( $text, Subscription $subscription ) {
335
-		$text = __( 'MemberPress', 'pronamic_ideal' ) . '<br />';
334
+	public static function subscription_source_text($text, Subscription $subscription) {
335
+		$text = __('MemberPress', 'pronamic_ideal') . '<br />';
336 336
 
337 337
 		$text .= sprintf(
338 338
 			'<a href="%s">%s</a>',
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 					'page'         => 'memberpress-subscriptions',
342 342
 					'subscription' => $subscription->source_id,
343 343
 				),
344
-				admin_url( 'admin.php' )
344
+				admin_url('admin.php')
345 345
 			),
346 346
 			/* translators: %s: payment source id */
347
-			sprintf( __( 'Subscription %s', 'pronamic_ideal' ), $subscription->source_id )
347
+			sprintf(__('Subscription %s', 'pronamic_ideal'), $subscription->source_id)
348 348
 		);
349 349
 
350 350
 		return $text;
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @return string
360 360
 	 */
361
-	public static function source_description( $description, Payment $payment ) {
362
-		return __( 'MemberPress Transaction', 'pronamic_ideal' );
361
+	public static function source_description($description, Payment $payment) {
362
+		return __('MemberPress Transaction', 'pronamic_ideal');
363 363
 	}
364 364
 
365 365
 	/**
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 	 *
371 371
 	 * @return string
372 372
 	 */
373
-	public static function subscription_source_description( $description, Subscription $subscription ) {
374
-		return __( 'MemberPress Subscription', 'pronamic_ideal' );
373
+	public static function subscription_source_description($description, Subscription $subscription) {
374
+		return __('MemberPress Subscription', 'pronamic_ideal');
375 375
 	}
376 376
 
377 377
 	/**
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @return string
384 384
 	 */
385
-	public static function source_url( $url, Payment $payment ) {
385
+	public static function source_url($url, Payment $payment) {
386 386
 		$url = add_query_arg(
387 387
 			array(
388 388
 				'page'   => 'memberpress-trans',
389 389
 				'action' => 'edit',
390 390
 				'id'     => $payment->source_id,
391 391
 			),
392
-			admin_url( 'admin.php' )
392
+			admin_url('admin.php')
393 393
 		);
394 394
 
395 395
 		return $url;
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
 	 *
404 404
 	 * @return string
405 405
 	 */
406
-	public static function subscription_source_url( $url, Subscription $subscription ) {
406
+	public static function subscription_source_url($url, Subscription $subscription) {
407 407
 		$url = add_query_arg(
408 408
 			array(
409 409
 				'page'         => 'memberpress-subscriptions',
410 410
 				'subscription' => $subscription->source_id,
411 411
 			),
412
-			admin_url( 'admin.php' )
412
+			admin_url('admin.php')
413 413
 		);
414 414
 
415 415
 		return $url;
@@ -426,16 +426,16 @@  discard block
 block discarded – undo
426 426
 	 * @param string           $status_new               New status identifier.
427 427
 	 * @param MeprSubscription $memberpress_subscription MemberPress subscription object.
428 428
 	 */
429
-	public function memberpress_subscription_transition_status( $status_old, $status_new, $memberpress_subscription ) {
430
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $memberpress_subscription->id );
429
+	public function memberpress_subscription_transition_status($status_old, $status_new, $memberpress_subscription) {
430
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $memberpress_subscription->id);
431 431
 
432
-		if ( empty( $subscription ) ) {
432
+		if (empty($subscription)) {
433 433
 			return;
434 434
 		}
435 435
 
436
-		$status = SubscriptionStatuses::transform( $status_new );
436
+		$status = SubscriptionStatuses::transform($status_new);
437 437
 
438
-		$subscription->set_status( $status );
438
+		$subscription->set_status($status);
439 439
 
440 440
 		$subscription->save();
441 441
 	}
Please login to merge, or discard this patch.
src/Gateway.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	public function __construct() {
56 56
 		// Set the name of this gateway.
57 57
 		// @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L12-13.
58
-		$this->name = __( 'Pronamic', 'pronamic_ideal' );
58
+		$this->name = __('Pronamic', 'pronamic_ideal');
59 59
 
60
-		if ( ! empty( $this->payment_method ) ) {
61
-			$this->name = PaymentMethods::get_name( $this->payment_method );
60
+		if ( ! empty($this->payment_method)) {
61
+			$this->name = PaymentMethods::get_name($this->payment_method);
62 62
 		}
63 63
 
64 64
 		// Set the default settings.
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param array $settings MemberPress gateway settings array.
82 82
 	 */
83
-	public function load( $settings ) {
83
+	public function load($settings) {
84 84
 		$this->settings = (object) $settings;
85 85
 
86 86
 		$this->set_defaults();
@@ -97,19 +97,19 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return mixed
99 99
 	 */
100
-	public function send_transaction_notices( $transaction, $method ) {
100
+	public function send_transaction_notices($transaction, $method) {
101 101
 		$class = 'MeprUtils';
102 102
 
103
-		if ( ! Core_Util::class_method_exists( $class, $method ) ) {
103
+		if ( ! Core_Util::class_method_exists($class, $method)) {
104 104
 			$class = $this;
105 105
 		}
106 106
 
107
-		if ( 'MeprUtils' === $class && 'send_product_welcome_notices' === $method ) {
107
+		if ('MeprUtils' === $class && 'send_product_welcome_notices' === $method) {
108 108
 			// `send_product_welcome_notices` is called from `send_signup_notices` in newer versions.
109 109
 			return;
110 110
 		}
111 111
 
112
-		return call_user_func( array( $class, $method ), $transaction );
112
+		return call_user_func(array($class, $method), $transaction);
113 113
 	}
114 114
 
115 115
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L72-73
138 138
 	 */
139 139
 	protected function set_defaults() {
140
-		if ( ! isset( $this->settings ) ) {
140
+		if ( ! isset($this->settings)) {
141 141
 			$this->settings = array();
142 142
 		}
143 143
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L119-122
177 177
 	 */
178
-	public function process_payment( $txn ) {
178
+	public function process_payment($txn) {
179 179
 
180 180
 	}
181 181
 
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$subscription = $transaction->subscription();
194 194
 
195
-		if ( $subscription ) {
196
-			if ( MeprSubscription::$active_str !== $subscription->status ) {
195
+		if ($subscription) {
196
+			if (MeprSubscription::$active_str !== $subscription->status) {
197 197
 				$subscription->status = MeprSubscription::$active_str;
198 198
 				$subscription->store();
199 199
 			}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 			$subscription->limit_payment_cycles();
204 204
 		}
205 205
 
206
-		$this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' );
206
+		$this->send_transaction_notices($transaction, 'send_transaction_receipt_notices');
207 207
 
208 208
 		return $transaction;
209 209
 	}
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 		// Expire associated transactions for subscription.
224 224
 		$subscription = $transaction->subscription();
225 225
 
226
-		if ( $subscription ) {
226
+		if ($subscription) {
227 227
 			$subscription->expire_txns();
228 228
 			$subscription->store();
229 229
 		}
230 230
 
231
-		$this->send_transaction_notices( $transaction, 'send_failed_txn_notices' );
231
+		$this->send_transaction_notices($transaction, 'send_failed_txn_notices');
232 232
 
233 233
 		return $transaction;
234 234
 	}
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 		$subscription = $transaction->subscription();
254 254
 
255
-		if ( $subscription ) {
255
+		if ($subscription) {
256 256
 			$subscription->status     = MeprSubscription::$active_str;
257 257
 			$subscription->created_at = $transaction->created_at;
258 258
 			$subscription->store();
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 		 * @link https://github.com/wp-premium/memberpress-business/blob/1.2.7/app/lib/MeprBaseGateway.php#L609-L619
267 267
 		 * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprTransaction.php#L51
268 268
 		 */
269
-		$reflection = new ReflectionClass( 'MeprBaseRealGateway' );
269
+		$reflection = new ReflectionClass('MeprBaseRealGateway');
270 270
 
271
-		if ( $reflection->hasMethod( 'send_product_welcome_notices' ) && 3 === $reflection->getMethod( 'send_product_welcome_notices' )->getNumberOfParameters() ) {
271
+		if ($reflection->hasMethod('send_product_welcome_notices') && 3 === $reflection->getMethod('send_product_welcome_notices')->getNumberOfParameters()) {
272 272
 			$uemail = MeprEmailFactory::fetch(
273 273
 				'MeprUserProductWelcomeEmail',
274 274
 				'MeprBaseProductEmail',
@@ -286,24 +286,24 @@  discard block
 block discarded – undo
286 286
 			 */
287 287
 			$this->send_product_welcome_notices(
288 288
 				$uemail,
289
-				MeprTransactionsHelper::get_email_params( $transaction ),
289
+				MeprTransactionsHelper::get_email_params($transaction),
290 290
 				$transaction->user()
291 291
 			);
292 292
 		} else {
293
-			$this->send_transaction_notices( $transaction, 'send_product_welcome_notices' );
293
+			$this->send_transaction_notices($transaction, 'send_product_welcome_notices');
294 294
 		}
295 295
 
296 296
 		// Send upgrade/downgrade notices.
297
-		if ( $upgrade ) {
298
-			$this->upgraded_sub( $transaction );
299
-			$this->send_transaction_notices( $transaction, 'send_upgraded_txn_notices' );
300
-		} elseif ( $downgrade ) {
301
-			$this->downgraded_sub( $transaction );
302
-			$this->send_transaction_notices( $transaction, 'send_downgraded_txn_notices' );
297
+		if ($upgrade) {
298
+			$this->upgraded_sub($transaction);
299
+			$this->send_transaction_notices($transaction, 'send_upgraded_txn_notices');
300
+		} elseif ($downgrade) {
301
+			$this->downgraded_sub($transaction);
302
+			$this->send_transaction_notices($transaction, 'send_downgraded_txn_notices');
303 303
 		}
304 304
 
305
-		$this->send_transaction_notices( $transaction, 'send_signup_notices' );
306
-		$this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' );
305
+		$this->send_transaction_notices($transaction, 'send_signup_notices');
306
+		$this->send_transaction_notices($transaction, 'send_transaction_receipt_notices');
307 307
 
308 308
 		return $transaction;
309 309
 	}
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L131-133
317 317
 	 */
318
-	public function process_refund( MeprTransaction $txn ) {
318
+	public function process_refund(MeprTransaction $txn) {
319 319
 
320 320
 	}
321 321
 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	 *
336 336
 	 * @param MeprTransaction $transaction MemberPress transaction object.
337 337
 	 */
338
-	public function process_trial_payment( $transaction ) {
338
+	public function process_trial_payment($transaction) {
339 339
 
340 340
 	}
341 341
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 *
347 347
 	 * @param MeprTransaction $transaction MemberPress transaction object.
348 348
 	 */
349
-	public function record_trial_payment( $transaction ) {
349
+	public function record_trial_payment($transaction) {
350 350
 
351 351
 	}
352 352
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	 *
358 358
 	 * @param MeprTransaction $txn MemberPress transaction object.
359 359
 	 */
360
-	public function process_create_subscription( $txn ) {
360
+	public function process_create_subscription($txn) {
361 361
 
362 362
 	}
363 363
 
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 *
379 379
 	 * @param int $sub_id Subscription ID.
380 380
 	 */
381
-	public function process_update_subscription( $sub_id ) {
381
+	public function process_update_subscription($sub_id) {
382 382
 
383 383
 	}
384 384
 
@@ -398,21 +398,21 @@  discard block
 block discarded – undo
398 398
 	 *
399 399
 	 * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L184-186
400 400
 	 */
401
-	public function process_suspend_subscription( $sub_id ) {
402
-		if ( ! MeprSubscription::exists( $sub_id ) ) {
401
+	public function process_suspend_subscription($sub_id) {
402
+		if ( ! MeprSubscription::exists($sub_id)) {
403 403
 			return;
404 404
 		}
405 405
 
406
-		$sub = new MeprSubscription( $sub_id );
406
+		$sub = new MeprSubscription($sub_id);
407 407
 
408
-		if ( MeprSubscription::$suspended_str === $sub->status ) {
408
+		if (MeprSubscription::$suspended_str === $sub->status) {
409 409
 			// Subscription is already suspended.
410 410
 			return;
411 411
 		}
412 412
 
413
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id );
413
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->id);
414 414
 
415
-		if ( ! $subscription ) {
415
+		if ( ! $subscription) {
416 416
 			return;
417 417
 		}
418 418
 
@@ -421,19 +421,19 @@  discard block
 block discarded – undo
421 421
 		$sub->store();
422 422
 
423 423
 		// Send suspended subscription notices.
424
-		MeprUtils::send_suspended_sub_notices( $sub );
424
+		MeprUtils::send_suspended_sub_notices($sub);
425 425
 
426 426
 		$note = sprintf(
427 427
 			/* translators: %s: MemberPress */
428
-			__( '%s subscription on hold.', 'pronamic_ideal' ),
429
-			__( 'MemberPress', 'pronamic_ideal' )
428
+			__('%s subscription on hold.', 'pronamic_ideal'),
429
+			__('MemberPress', 'pronamic_ideal')
430 430
 		);
431 431
 
432
-		$subscription->add_note( $note );
432
+		$subscription->add_note($note);
433 433
 
434 434
 		// The status of canceled or completed subscriptions will not be changed automatically.
435
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
436
-			$subscription->set_status( Statuses::OPEN );
435
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
436
+			$subscription->set_status(Statuses::OPEN);
437 437
 
438 438
 			$subscription->save();
439 439
 		}
@@ -455,21 +455,21 @@  discard block
 block discarded – undo
455 455
 	 *
456 456
 	 * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L193-195
457 457
 	 */
458
-	public function process_resume_subscription( $sub_id ) {
459
-		if ( ! MeprSubscription::exists( $sub_id ) ) {
458
+	public function process_resume_subscription($sub_id) {
459
+		if ( ! MeprSubscription::exists($sub_id)) {
460 460
 			return;
461 461
 		}
462 462
 
463
-		$sub = new MeprSubscription( $sub_id );
463
+		$sub = new MeprSubscription($sub_id);
464 464
 
465
-		if ( MeprSubscription::$active_str === $sub->status ) {
465
+		if (MeprSubscription::$active_str === $sub->status) {
466 466
 			// Subscription is already active.
467 467
 			return;
468 468
 		}
469 469
 
470
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id );
470
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->id);
471 471
 
472
-		if ( ! $subscription ) {
472
+		if ( ! $subscription) {
473 473
 			return;
474 474
 		}
475 475
 
@@ -480,35 +480,35 @@  discard block
 block discarded – undo
480 480
 		// Check if prior txn is expired yet or not, if so create a temporary txn so the user can access the content immediately.
481 481
 		$prior_txn = $sub->latest_txn();
482 482
 
483
-		if ( false === $prior_txn || ! ( $prior_txn instanceof MeprTransaction ) || strtotime( $prior_txn->expires_at ) < time() ) {
483
+		if (false === $prior_txn || ! ($prior_txn instanceof MeprTransaction) || strtotime($prior_txn->expires_at) < time()) {
484 484
 			$txn                  = new MeprTransaction();
485 485
 			$txn->subscription_id = $sub->id;
486 486
 			$txn->trans_num       = $sub->subscr_id . '-' . uniqid();
487 487
 			$txn->status          = MeprTransaction::$confirmed_str;
488 488
 			$txn->txn_type        = MeprTransaction::$subscription_confirmation_str;
489 489
 			$txn->response        = (string) $sub;
490
-			$txn->expires_at      = MeprUtils::ts_to_mysql_date( time() + MeprUtils::days( 1 ), 'Y-m-d 23:59:59' );
490
+			$txn->expires_at      = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days(1), 'Y-m-d 23:59:59');
491 491
 
492
-			$txn->set_subtotal( 0.00 ); // Just a confirmation txn.
492
+			$txn->set_subtotal(0.00); // Just a confirmation txn.
493 493
 
494 494
 			$txn->store();
495 495
 		}
496 496
 
497 497
 		// Send resumed subscription notices.
498
-		MeprUtils::send_resumed_sub_notices( $sub );
498
+		MeprUtils::send_resumed_sub_notices($sub);
499 499
 
500 500
 		// Add note.
501 501
 		$note = sprintf(
502 502
 			/* translators: %s: MemberPress */
503
-			__( '%s subscription reactivated.', 'pronamic_ideal' ),
504
-			__( 'MemberPress', 'pronamic_ideal' )
503
+			__('%s subscription reactivated.', 'pronamic_ideal'),
504
+			__('MemberPress', 'pronamic_ideal')
505 505
 		);
506 506
 
507
-		$subscription->add_note( $note );
507
+		$subscription->add_note($note);
508 508
 
509 509
 		// The status of canceled or completed subscriptions will not be changed automatically.
510
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
511
-			$subscription->set_status( Statuses::ACTIVE );
510
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
511
+			$subscription->set_status(Statuses::ACTIVE);
512 512
 
513 513
 			$subscription->save();
514 514
 		}
@@ -530,21 +530,21 @@  discard block
 block discarded – undo
530 530
 	 *
531 531
 	 * @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L202-206
532 532
 	 */
533
-	public function process_cancel_subscription( $sub_id ) {
534
-		if ( ! MeprSubscription::exists( $sub_id ) ) {
533
+	public function process_cancel_subscription($sub_id) {
534
+		if ( ! MeprSubscription::exists($sub_id)) {
535 535
 			return;
536 536
 		}
537 537
 
538
-		$sub = new MeprSubscription( $sub_id );
538
+		$sub = new MeprSubscription($sub_id);
539 539
 
540
-		if ( MeprSubscription::$cancelled_str === $sub->status ) {
540
+		if (MeprSubscription::$cancelled_str === $sub->status) {
541 541
 			// Subscription is already cancelled.
542 542
 			return;
543 543
 		}
544 544
 
545
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id );
545
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->id);
546 546
 
547
-		if ( ! $subscription ) {
547
+		if ( ! $subscription) {
548 548
 			return;
549 549
 		}
550 550
 
@@ -553,27 +553,27 @@  discard block
 block discarded – undo
553 553
 		$sub->store();
554 554
 
555 555
 		// Expire the grace period (confirmation) if no completed payments have come through.
556
-		if ( (int) $sub->txn_count <= 0 ) {
556
+		if ((int) $sub->txn_count <= 0) {
557 557
 			$sub->expire_txns();
558 558
 		}
559 559
 
560 560
 		$sub->limit_reached_actions();
561 561
 
562 562
 		// Send cancelled subscription notices.
563
-		MeprUtils::send_cancelled_sub_notices( $sub );
563
+		MeprUtils::send_cancelled_sub_notices($sub);
564 564
 
565 565
 		// Add note.
566 566
 		$note = sprintf(
567 567
 			/* translators: %s: MemberPress */
568
-			__( '%s subscription cancelled.', 'pronamic_ideal' ),
569
-			__( 'MemberPress', 'pronamic_ideal' )
568
+			__('%s subscription cancelled.', 'pronamic_ideal'),
569
+			__('MemberPress', 'pronamic_ideal')
570 570
 		);
571 571
 
572
-		$subscription->add_note( $note );
572
+		$subscription->add_note($note);
573 573
 
574 574
 		// The status of canceled or completed subscriptions will not be changed automatically.
575
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
576
-			$subscription->set_status( Statuses::CANCELLED );
575
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
576
+			$subscription->set_status(Statuses::CANCELLED);
577 577
 
578 578
 			$subscription->save();
579 579
 		}
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 *
601 601
 	 * @param MeprTransaction $txn MemberPress transaction object.
602 602
 	 */
603
-	public function process_signup_form( $txn ) {
603
+	public function process_signup_form($txn) {
604 604
 
605 605
 	}
606 606
 
@@ -611,28 +611,28 @@  discard block
 block discarded – undo
611 611
 	 *
612 612
 	 * @param MeprTransaction $txn MemberPress transaction object.
613 613
 	 */
614
-	public function payment_redirect( $txn ) {
615
-		$txn = new MeprTransaction( $txn->id );
614
+	public function payment_redirect($txn) {
615
+		$txn = new MeprTransaction($txn->id);
616 616
 
617 617
 		// Gateway.
618 618
 		$config_id = $this->settings->config_id;
619 619
 
620
-		$gateway = Plugin::get_gateway( $config_id );
620
+		$gateway = Plugin::get_gateway($config_id);
621 621
 
622
-		if ( ! $gateway ) {
622
+		if ( ! $gateway) {
623 623
 			return;
624 624
 		}
625 625
 
626 626
 		// Data.
627
-		$data = new PaymentData( $txn, $this );
627
+		$data = new PaymentData($txn, $this);
628 628
 
629
-		$payment = Plugin::start( $config_id, $gateway, $data, $this->payment_method );
629
+		$payment = Plugin::start($config_id, $gateway, $data, $this->payment_method);
630 630
 
631 631
 		$error = $gateway->get_error();
632 632
 
633
-		if ( ! is_wp_error( $error ) ) {
633
+		if ( ! is_wp_error($error)) {
634 634
 			// Redirect.
635
-			$gateway->redirect( $payment );
635
+			$gateway->redirect($payment);
636 636
 		}
637 637
 	}
638 638
 
@@ -645,14 +645,14 @@  discard block
 block discarded – undo
645 645
 	 *
646 646
 	 * @param MeprTransaction $txn MemberPress transaction object.
647 647
 	 */
648
-	public function display_payment_page( $txn ) {
648
+	public function display_payment_page($txn) {
649 649
 		// Gateway.
650 650
 		$config_id = $this->settings->config_id;
651 651
 
652
-		$gateway = Plugin::get_gateway( $config_id );
652
+		$gateway = Plugin::get_gateway($config_id);
653 653
 
654
-		if ( $gateway && '' === $gateway->get_input_html() ) {
655
-			$this->payment_redirect( $txn );
654
+		if ($gateway && '' === $gateway->get_input_html()) {
655
+			$this->payment_redirect($txn);
656 656
 		}
657 657
 	}
658 658
 
@@ -666,18 +666,18 @@  discard block
 block discarded – undo
666 666
 	 * @param  MeprTransaction $txn MemberPress transaction object.
667 667
 	 * @return bool
668 668
 	 */
669
-	public function process_payment_form( $txn ) {
670
-		if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) {
669
+	public function process_payment_form($txn) {
670
+		if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_memberpress_pay')) {
671 671
 			return false;
672 672
 		}
673 673
 
674 674
 		// Gateway.
675 675
 		$config_id = $this->settings->config_id;
676 676
 
677
-		$gateway = Plugin::get_gateway( $config_id );
677
+		$gateway = Plugin::get_gateway($config_id);
678 678
 
679
-		if ( $gateway ) {
680
-			$this->payment_redirect( $txn );
679
+		if ($gateway) {
680
+			$this->payment_redirect($txn);
681 681
 		}
682 682
 	}
683 683
 
@@ -705,20 +705,20 @@  discard block
 block discarded – undo
705 705
 	 * @param int      $product_id Product ID.
706 706
 	 * @param int      $txn_id     Transaction ID.
707 707
 	 */
708
-	public function display_payment_form( $amount, $user, $product_id, $txn_id ) {
709
-		$product = new MeprProduct( $product_id );
708
+	public function display_payment_form($amount, $user, $product_id, $txn_id) {
709
+		$product = new MeprProduct($product_id);
710 710
 
711 711
 		$coupon = false;
712 712
 
713
-		$txn = new MeprTransaction( $txn_id );
713
+		$txn = new MeprTransaction($txn_id);
714 714
 
715 715
 		// Artifically set the price of the $prd in case a coupon was used.
716
-		if ( $product->price !== $amount ) {
716
+		if ($product->price !== $amount) {
717 717
 			$coupon         = true;
718 718
 			$product->price = $amount;
719 719
 		}
720 720
 
721
-		$invoice = MeprTransactionsHelper::get_invoice( $txn );
721
+		$invoice = MeprTransactionsHelper::get_invoice($txn);
722 722
 
723 723
 		echo $invoice; // WPCS: XSS ok.
724 724
 
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 		<div class="mp_wrapper mp_payment_form_wrapper">
727 727
 			<form action="" method="post" id="payment-form" class="mepr-form" novalidate>
728 728
 				<input type="hidden" name="mepr_process_payment_form" value="Y"/>
729
-				<input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/>
729
+				<input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr($txn_id); ?>"/>
730 730
 				<input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/>
731 731
 
732 732
 				<div class="mepr_spacer">&nbsp;</div>
@@ -736,9 +736,9 @@  discard block
 block discarded – undo
736 736
 				// Gateway.
737 737
 				$config_id = $this->settings->config_id;
738 738
 
739
-				$gateway = Plugin::get_gateway( $config_id );
739
+				$gateway = Plugin::get_gateway($config_id);
740 740
 
741
-				if ( $gateway ) {
741
+				if ($gateway) {
742 742
 					echo $gateway->get_input_html(); // WPCS: XSS ok.
743 743
 				}
744 744
 
@@ -746,13 +746,13 @@  discard block
 block discarded – undo
746 746
 
747 747
 				<div class="mepr_spacer">&nbsp;</div>
748 748
 
749
-				<input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/>
750
-				<img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/>
751
-				<?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?>
749
+				<input type="submit" class="mepr-submit" value="<?php esc_attr_e('Pay', 'pronamic_ideal'); ?>"/>
750
+				<img src="<?php echo esc_attr(admin_url('images/loading.gif')); ?>" style="display: none;" class="mepr-loading-gif"/>
751
+				<?php MeprView::render('/shared/has_errors', get_defined_vars()); ?>
752 752
 
753 753
 				<noscript>
754 754
 					<p class="mepr_nojs">
755
-						<?php esc_html_e( 'JavaScript is disabled in your browser. You will not be able to complete your purchase until you either enable JavaScript in your browser, or switch to a browser that supports it.', 'pronamic_ideal' ); ?>
755
+						<?php esc_html_e('JavaScript is disabled in your browser. You will not be able to complete your purchase until you either enable JavaScript in your browser, or switch to a browser that supports it.', 'pronamic_ideal'); ?>
756 756
 					</p>
757 757
 				</noscript>
758 758
 			</form>
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 	 * @param array $errors Array with errors.
771 771
 	 * @return array
772 772
 	 */
773
-	public function validate_payment_form( $errors ) {
773
+	public function validate_payment_form($errors) {
774 774
 		return $errors;
775 775
 	}
776 776
 
@@ -797,18 +797,18 @@  discard block
 block discarded – undo
797 797
 
798 798
 				?>
799 799
 				<td>
800
-					<?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?>
800
+					<?php esc_html_e('Configuration', 'pronamic_ideal'); ?>
801 801
 				</td>
802 802
 				<td>
803
-					<select name="<?php echo esc_attr( $name ); ?>">
803
+					<select name="<?php echo esc_attr($name); ?>">
804 804
 						<?php
805 805
 
806
-						foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) {
806
+						foreach (Plugin::get_config_select_options($this->payment_method) as $value => $label) {
807 807
 							printf(
808 808
 								'<option value="%s" %s>%s</option>',
809
-								esc_attr( $value ),
810
-								selected( $value, $this->settings->config_id, false ),
811
-								esc_html( $label )
809
+								esc_attr($value),
810
+								selected($value, $this->settings->config_id, false),
811
+								esc_html($label)
812 812
 							);
813 813
 						}
814 814
 
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 	 * @param array $errors Array with errors.
831 831
 	 * @return array
832 832
 	 */
833
-	public function validate_options_form( $errors ) {
833
+	public function validate_options_form($errors) {
834 834
 		return $errors;
835 835
 	}
836 836
 
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 	 * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168
856 856
 	 * @link https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388
857 857
 	 */
858
-	public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) {
858
+	public function display_update_account_form($sub_id, $errors = array(), $message = '') {
859 859
 
860 860
 	}
861 861
 
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 	 * @param  array $errors Array with errors.
869 869
 	 * @return array
870 870
 	 */
871
-	public function validate_update_account_form( $errors = array() ) {
871
+	public function validate_update_account_form($errors = array()) {
872 872
 		return $errors;
873 873
 	}
874 874
 
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 	 *
881 881
 	 * @param int $sub_id Subscription ID.
882 882
 	 */
883
-	public function process_update_account_form( $sub_id ) {
883
+	public function process_update_account_form($sub_id) {
884 884
 
885 885
 	}
886 886
 
Please login to merge, or discard this patch.