@@ -8,4 +8,4 @@ |
||
| 8 | 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -class_alias( 'Pronamic\WordPress\Pay\Extensions\MemberPress\DirectDebitIDealGateway', 'MeprDirectDebitIDealGateway' ); |
|
| 11 | +class_alias('Pronamic\WordPress\Pay\Extensions\MemberPress\DirectDebitIDealGateway', 'MeprDirectDebitIDealGateway'); |
|
@@ -8,4 +8,4 @@ |
||
| 8 | 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -class_alias( 'Pronamic\WordPress\Pay\Extensions\MemberPress\IDealGateway', 'MeprIDealGateway' ); |
|
| 11 | +class_alias('Pronamic\WordPress\Pay\Extensions\MemberPress\IDealGateway', 'MeprIDealGateway'); |
|
@@ -8,4 +8,4 @@ |
||
| 8 | 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -class_alias( 'Pronamic\WordPress\Pay\Extensions\MemberPress\BancontactGateway', 'MeprMisterCashGateway' ); |
|
| 11 | +class_alias('Pronamic\WordPress\Pay\Extensions\MemberPress\BancontactGateway', 'MeprMisterCashGateway'); |
|
@@ -8,4 +8,4 @@ |
||
| 8 | 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -class_alias( 'Pronamic\WordPress\Pay\Extensions\MemberPress\PayPalGateway', 'MeprPronamicPayPalGateway' ); |
|
| 11 | +class_alias('Pronamic\WordPress\Pay\Extensions\MemberPress\PayPalGateway', 'MeprPronamicPayPalGateway'); |
|
@@ -28,8 +28,8 @@ |
||
| 28 | 28 | * |
| 29 | 29 | * @param string $status MemberPress subscription status value. |
| 30 | 30 | */ |
| 31 | - public static function transform( $status ) { |
|
| 32 | - switch ( $status ) { |
|
| 31 | + public static function transform($status) { |
|
| 32 | + switch ($status) { |
|
| 33 | 33 | case MeprSubscription::$pending_str: |
| 34 | 34 | return Statuses::OPEN; |
| 35 | 35 | case MeprSubscription::$active_str: |
@@ -8,4 +8,4 @@ |
||
| 8 | 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -class_alias( 'Pronamic\WordPress\Pay\Extensions\MemberPress\DirectDebitBancontactGateway', 'MeprDirectDebitBancontactGateway' ); |
|
| 11 | +class_alias('Pronamic\WordPress\Pay\Extensions\MemberPress\DirectDebitBancontactGateway', 'MeprDirectDebitBancontactGateway'); |
|
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | * @return string |
| 36 | 36 | */ |
| 37 | 37 | protected function get_icon() { |
| 38 | - return plugins_url( 'images/bancontact/icon-32x32.png', Plugin::$file ); |
|
| 38 | + return plugins_url('images/bancontact/icon-32x32.png', Plugin::$file); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | public function __construct() { |
| 56 | 56 | // Set the name of this gateway. |
| 57 | 57 | // @see 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 |
||
| 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 |
||
| 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 |
||
| 137 | 137 | * @see 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 |
||
| 175 | 175 | * |
| 176 | 176 | * @see 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 | |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $subscription = $transaction->subscription(); |
| 196 | 196 | |
| 197 | - if ( $subscription ) { |
|
| 198 | - if ( MeprSubscription::$active_str !== $subscription->status ) { |
|
| 197 | + if ($subscription) { |
|
| 198 | + if (MeprSubscription::$active_str !== $subscription->status) { |
|
| 199 | 199 | $subscription->status = MeprSubscription::$active_str; |
| 200 | 200 | $subscription->store(); |
| 201 | 201 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $subscription->limit_payment_cycles(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); |
|
| 208 | + $this->send_transaction_notices($transaction, 'send_transaction_receipt_notices'); |
|
| 209 | 209 | |
| 210 | 210 | return $transaction; |
| 211 | 211 | } |
@@ -225,12 +225,12 @@ discard block |
||
| 225 | 225 | // Expire associated transactions for subscription. |
| 226 | 226 | $subscription = $transaction->subscription(); |
| 227 | 227 | |
| 228 | - if ( $subscription ) { |
|
| 228 | + if ($subscription) { |
|
| 229 | 229 | $subscription->expire_txns(); |
| 230 | 230 | $subscription->store(); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $this->send_transaction_notices( $transaction, 'send_failed_txn_notices' ); |
|
| 233 | + $this->send_transaction_notices($transaction, 'send_failed_txn_notices'); |
|
| 234 | 234 | |
| 235 | 235 | return $transaction; |
| 236 | 236 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | $subscription = $transaction->subscription(); |
| 256 | 256 | |
| 257 | - if ( $subscription ) { |
|
| 257 | + if ($subscription) { |
|
| 258 | 258 | $subscription->status = MeprSubscription::$active_str; |
| 259 | 259 | $subscription->created_at = $transaction->created_at; |
| 260 | 260 | $subscription->store(); |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | * @see https://github.com/wp-premium/memberpress-business/blob/1.2.7/app/lib/MeprBaseGateway.php#L609-L619 |
| 269 | 269 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprTransaction.php#L51 |
| 270 | 270 | */ |
| 271 | - $reflection = new ReflectionClass( 'MeprBaseRealGateway' ); |
|
| 271 | + $reflection = new ReflectionClass('MeprBaseRealGateway'); |
|
| 272 | 272 | |
| 273 | - if ( $reflection->hasMethod( 'send_product_welcome_notices' ) && 3 === $reflection->getMethod( 'send_product_welcome_notices' )->getNumberOfParameters() ) { |
|
| 273 | + if ($reflection->hasMethod('send_product_welcome_notices') && 3 === $reflection->getMethod('send_product_welcome_notices')->getNumberOfParameters()) { |
|
| 274 | 274 | $uemail = MeprEmailFactory::fetch( |
| 275 | 275 | 'MeprUserProductWelcomeEmail', |
| 276 | 276 | 'MeprBaseProductEmail', |
@@ -288,24 +288,24 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | $this->send_product_welcome_notices( |
| 290 | 290 | $uemail, |
| 291 | - MeprTransactionsHelper::get_email_params( $transaction ), |
|
| 291 | + MeprTransactionsHelper::get_email_params($transaction), |
|
| 292 | 292 | $transaction->user() |
| 293 | 293 | ); |
| 294 | 294 | } else { |
| 295 | - $this->send_transaction_notices( $transaction, 'send_product_welcome_notices' ); |
|
| 295 | + $this->send_transaction_notices($transaction, 'send_product_welcome_notices'); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | // Send upgrade/downgrade notices. |
| 299 | - if ( $upgrade ) { |
|
| 300 | - $this->upgraded_sub( $transaction ); |
|
| 301 | - $this->send_transaction_notices( $transaction, 'send_upgraded_txn_notices' ); |
|
| 302 | - } elseif ( $downgrade ) { |
|
| 303 | - $this->downgraded_sub( $transaction ); |
|
| 304 | - $this->send_transaction_notices( $transaction, 'send_downgraded_txn_notices' ); |
|
| 299 | + if ($upgrade) { |
|
| 300 | + $this->upgraded_sub($transaction); |
|
| 301 | + $this->send_transaction_notices($transaction, 'send_upgraded_txn_notices'); |
|
| 302 | + } elseif ($downgrade) { |
|
| 303 | + $this->downgraded_sub($transaction); |
|
| 304 | + $this->send_transaction_notices($transaction, 'send_downgraded_txn_notices'); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - $this->send_transaction_notices( $transaction, 'send_signup_notices' ); |
|
| 308 | - $this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' ); |
|
| 307 | + $this->send_transaction_notices($transaction, 'send_signup_notices'); |
|
| 308 | + $this->send_transaction_notices($transaction, 'send_transaction_receipt_notices'); |
|
| 309 | 309 | |
| 310 | 310 | return $transaction; |
| 311 | 311 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L131-133 |
| 319 | 319 | */ |
| 320 | - public function process_refund( MeprTransaction $txn ) { |
|
| 320 | + public function process_refund(MeprTransaction $txn) { |
|
| 321 | 321 | |
| 322 | 322 | } |
| 323 | 323 | |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | * |
| 338 | 338 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 339 | 339 | */ |
| 340 | - public function process_trial_payment( $transaction ) { |
|
| 340 | + public function process_trial_payment($transaction) { |
|
| 341 | 341 | |
| 342 | 342 | } |
| 343 | 343 | |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @param MeprTransaction $transaction MemberPress transaction object. |
| 350 | 350 | */ |
| 351 | - public function record_trial_payment( $transaction ) { |
|
| 351 | + public function record_trial_payment($transaction) { |
|
| 352 | 352 | |
| 353 | 353 | } |
| 354 | 354 | |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | * |
| 360 | 360 | * @param MeprTransaction $txn MemberPress transaction object. |
| 361 | 361 | */ |
| 362 | - public function process_create_subscription( $txn ) { |
|
| 362 | + public function process_create_subscription($txn) { |
|
| 363 | 363 | |
| 364 | 364 | } |
| 365 | 365 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * |
| 381 | 381 | * @param int $sub_id Subscription ID. |
| 382 | 382 | */ |
| 383 | - public function process_update_subscription( $sub_id ) { |
|
| 383 | + public function process_update_subscription($sub_id) { |
|
| 384 | 384 | |
| 385 | 385 | } |
| 386 | 386 | |
@@ -400,21 +400,21 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L184-186 |
| 402 | 402 | */ |
| 403 | - public function process_suspend_subscription( $sub_id ) { |
|
| 404 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 403 | + public function process_suspend_subscription($sub_id) { |
|
| 404 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 405 | 405 | return; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - $sub = new MeprSubscription( $sub_id ); |
|
| 408 | + $sub = new MeprSubscription($sub_id); |
|
| 409 | 409 | |
| 410 | - if ( MeprSubscription::$suspended_str === $sub->status ) { |
|
| 410 | + if (MeprSubscription::$suspended_str === $sub->status) { |
|
| 411 | 411 | // Subscription is already suspended. |
| 412 | 412 | return; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id ); |
|
| 415 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->id); |
|
| 416 | 416 | |
| 417 | - if ( ! $subscription ) { |
|
| 417 | + if ( ! $subscription) { |
|
| 418 | 418 | return; |
| 419 | 419 | } |
| 420 | 420 | |
@@ -423,19 +423,19 @@ discard block |
||
| 423 | 423 | $sub->store(); |
| 424 | 424 | |
| 425 | 425 | // Send suspended subscription notices. |
| 426 | - MeprUtils::send_suspended_sub_notices( $sub ); |
|
| 426 | + MeprUtils::send_suspended_sub_notices($sub); |
|
| 427 | 427 | |
| 428 | 428 | $note = sprintf( |
| 429 | 429 | /* translators: %s: MemberPress */ |
| 430 | - __( '%s subscription on hold.', 'pronamic_ideal' ), |
|
| 431 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 430 | + __('%s subscription on hold.', 'pronamic_ideal'), |
|
| 431 | + __('MemberPress', 'pronamic_ideal') |
|
| 432 | 432 | ); |
| 433 | 433 | |
| 434 | - $subscription->add_note( $note ); |
|
| 434 | + $subscription->add_note($note); |
|
| 435 | 435 | |
| 436 | 436 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 437 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 438 | - $subscription->set_status( Statuses::OPEN ); |
|
| 437 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 438 | + $subscription->set_status(Statuses::OPEN); |
|
| 439 | 439 | |
| 440 | 440 | $subscription->save(); |
| 441 | 441 | } |
@@ -457,21 +457,21 @@ discard block |
||
| 457 | 457 | * |
| 458 | 458 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L193-195 |
| 459 | 459 | */ |
| 460 | - public function process_resume_subscription( $sub_id ) { |
|
| 461 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 460 | + public function process_resume_subscription($sub_id) { |
|
| 461 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 462 | 462 | return; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - $sub = new MeprSubscription( $sub_id ); |
|
| 465 | + $sub = new MeprSubscription($sub_id); |
|
| 466 | 466 | |
| 467 | - if ( MeprSubscription::$active_str === $sub->status ) { |
|
| 467 | + if (MeprSubscription::$active_str === $sub->status) { |
|
| 468 | 468 | // Subscription is already active. |
| 469 | 469 | return; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id ); |
|
| 472 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->id); |
|
| 473 | 473 | |
| 474 | - if ( ! $subscription ) { |
|
| 474 | + if ( ! $subscription) { |
|
| 475 | 475 | return; |
| 476 | 476 | } |
| 477 | 477 | |
@@ -482,35 +482,35 @@ discard block |
||
| 482 | 482 | // Check if prior txn is expired yet or not, if so create a temporary txn so the user can access the content immediately. |
| 483 | 483 | $prior_txn = $sub->latest_txn(); |
| 484 | 484 | |
| 485 | - if ( false === $prior_txn || ! ( $prior_txn instanceof MeprTransaction ) || strtotime( $prior_txn->expires_at ) < time() ) { |
|
| 485 | + if (false === $prior_txn || ! ($prior_txn instanceof MeprTransaction) || strtotime($prior_txn->expires_at) < time()) { |
|
| 486 | 486 | $txn = new MeprTransaction(); |
| 487 | 487 | $txn->subscription_id = $sub->id; |
| 488 | 488 | $txn->trans_num = $sub->subscr_id . '-' . uniqid(); |
| 489 | 489 | $txn->status = MeprTransaction::$confirmed_str; |
| 490 | 490 | $txn->txn_type = MeprTransaction::$subscription_confirmation_str; |
| 491 | 491 | $txn->response = (string) $sub; |
| 492 | - $txn->expires_at = MeprUtils::ts_to_mysql_date( time() + MeprUtils::days( 1 ), 'Y-m-d 23:59:59' ); |
|
| 492 | + $txn->expires_at = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days(1), 'Y-m-d 23:59:59'); |
|
| 493 | 493 | |
| 494 | - $txn->set_subtotal( 0.00 ); // Just a confirmation txn. |
|
| 494 | + $txn->set_subtotal(0.00); // Just a confirmation txn. |
|
| 495 | 495 | |
| 496 | 496 | $txn->store(); |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | // Send resumed subscription notices. |
| 500 | - MeprUtils::send_resumed_sub_notices( $sub ); |
|
| 500 | + MeprUtils::send_resumed_sub_notices($sub); |
|
| 501 | 501 | |
| 502 | 502 | // Add note. |
| 503 | 503 | $note = sprintf( |
| 504 | 504 | /* translators: %s: MemberPress */ |
| 505 | - __( '%s subscription reactivated.', 'pronamic_ideal' ), |
|
| 506 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 505 | + __('%s subscription reactivated.', 'pronamic_ideal'), |
|
| 506 | + __('MemberPress', 'pronamic_ideal') |
|
| 507 | 507 | ); |
| 508 | 508 | |
| 509 | - $subscription->add_note( $note ); |
|
| 509 | + $subscription->add_note($note); |
|
| 510 | 510 | |
| 511 | 511 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 512 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 513 | - $subscription->set_status( Statuses::ACTIVE ); |
|
| 512 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 513 | + $subscription->set_status(Statuses::ACTIVE); |
|
| 514 | 514 | |
| 515 | 515 | $subscription->save(); |
| 516 | 516 | } |
@@ -532,21 +532,21 @@ discard block |
||
| 532 | 532 | * |
| 533 | 533 | * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L202-206 |
| 534 | 534 | */ |
| 535 | - public function process_cancel_subscription( $sub_id ) { |
|
| 536 | - if ( ! MeprSubscription::exists( $sub_id ) ) { |
|
| 535 | + public function process_cancel_subscription($sub_id) { |
|
| 536 | + if ( ! MeprSubscription::exists($sub_id)) { |
|
| 537 | 537 | return; |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - $sub = new MeprSubscription( $sub_id ); |
|
| 540 | + $sub = new MeprSubscription($sub_id); |
|
| 541 | 541 | |
| 542 | - if ( MeprSubscription::$cancelled_str === $sub->status ) { |
|
| 542 | + if (MeprSubscription::$cancelled_str === $sub->status) { |
|
| 543 | 543 | // Subscription is already cancelled. |
| 544 | 544 | return; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->id ); |
|
| 547 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->id); |
|
| 548 | 548 | |
| 549 | - if ( ! $subscription ) { |
|
| 549 | + if ( ! $subscription) { |
|
| 550 | 550 | return; |
| 551 | 551 | } |
| 552 | 552 | |
@@ -555,27 +555,27 @@ discard block |
||
| 555 | 555 | $sub->store(); |
| 556 | 556 | |
| 557 | 557 | // Expire the grace period (confirmation) if no completed payments have come through. |
| 558 | - if ( (int) $sub->txn_count <= 0 ) { |
|
| 558 | + if ((int) $sub->txn_count <= 0) { |
|
| 559 | 559 | $sub->expire_txns(); |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | $sub->limit_reached_actions(); |
| 563 | 563 | |
| 564 | 564 | // Send cancelled subscription notices. |
| 565 | - MeprUtils::send_cancelled_sub_notices( $sub ); |
|
| 565 | + MeprUtils::send_cancelled_sub_notices($sub); |
|
| 566 | 566 | |
| 567 | 567 | // Add note. |
| 568 | 568 | $note = sprintf( |
| 569 | 569 | /* translators: %s: MemberPress */ |
| 570 | - __( '%s subscription cancelled.', 'pronamic_ideal' ), |
|
| 571 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
| 570 | + __('%s subscription cancelled.', 'pronamic_ideal'), |
|
| 571 | + __('MemberPress', 'pronamic_ideal') |
|
| 572 | 572 | ); |
| 573 | 573 | |
| 574 | - $subscription->add_note( $note ); |
|
| 574 | + $subscription->add_note($note); |
|
| 575 | 575 | |
| 576 | 576 | // The status of canceled or completed subscriptions will not be changed automatically. |
| 577 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
| 578 | - $subscription->set_status( Statuses::CANCELLED ); |
|
| 577 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
| 578 | + $subscription->set_status(Statuses::CANCELLED); |
|
| 579 | 579 | |
| 580 | 580 | $subscription->save(); |
| 581 | 581 | } |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | * |
| 603 | 603 | * @param MeprTransaction $txn MemberPress transaction object. |
| 604 | 604 | */ |
| 605 | - public function process_signup_form( $txn ) { |
|
| 605 | + public function process_signup_form($txn) { |
|
| 606 | 606 | |
| 607 | 607 | } |
| 608 | 608 | |
@@ -613,28 +613,28 @@ discard block |
||
| 613 | 613 | * |
| 614 | 614 | * @param MeprTransaction $txn MemberPress transaction object. |
| 615 | 615 | */ |
| 616 | - public function payment_redirect( $txn ) { |
|
| 617 | - $txn = new MeprTransaction( $txn->id ); |
|
| 616 | + public function payment_redirect($txn) { |
|
| 617 | + $txn = new MeprTransaction($txn->id); |
|
| 618 | 618 | |
| 619 | 619 | // Gateway. |
| 620 | 620 | $config_id = $this->settings->config_id; |
| 621 | 621 | |
| 622 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 622 | + $gateway = Plugin::get_gateway($config_id); |
|
| 623 | 623 | |
| 624 | - if ( ! $gateway ) { |
|
| 624 | + if ( ! $gateway) { |
|
| 625 | 625 | return; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | // Data. |
| 629 | - $data = new PaymentData( $txn, $this ); |
|
| 629 | + $data = new PaymentData($txn, $this); |
|
| 630 | 630 | |
| 631 | - $payment = Plugin::start( $config_id, $gateway, $data, $this->payment_method ); |
|
| 631 | + $payment = Plugin::start($config_id, $gateway, $data, $this->payment_method); |
|
| 632 | 632 | |
| 633 | 633 | $error = $gateway->get_error(); |
| 634 | 634 | |
| 635 | - if ( ! is_wp_error( $error ) ) { |
|
| 635 | + if ( ! is_wp_error($error)) { |
|
| 636 | 636 | // Redirect. |
| 637 | - $gateway->redirect( $payment ); |
|
| 637 | + $gateway->redirect($payment); |
|
| 638 | 638 | } |
| 639 | 639 | } |
| 640 | 640 | |
@@ -647,14 +647,14 @@ discard block |
||
| 647 | 647 | * |
| 648 | 648 | * @param MeprTransaction $txn MemberPress transaction object. |
| 649 | 649 | */ |
| 650 | - public function display_payment_page( $txn ) { |
|
| 650 | + public function display_payment_page($txn) { |
|
| 651 | 651 | // Gateway. |
| 652 | 652 | $config_id = $this->settings->config_id; |
| 653 | 653 | |
| 654 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 654 | + $gateway = Plugin::get_gateway($config_id); |
|
| 655 | 655 | |
| 656 | - if ( $gateway && '' === $gateway->get_input_html() ) { |
|
| 657 | - $this->payment_redirect( $txn ); |
|
| 656 | + if ($gateway && '' === $gateway->get_input_html()) { |
|
| 657 | + $this->payment_redirect($txn); |
|
| 658 | 658 | } |
| 659 | 659 | } |
| 660 | 660 | |
@@ -668,18 +668,18 @@ discard block |
||
| 668 | 668 | * @param MeprTransaction $txn MemberPress transaction object. |
| 669 | 669 | * @return bool |
| 670 | 670 | */ |
| 671 | - public function process_payment_form( $txn ) { |
|
| 672 | - if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) { |
|
| 671 | + public function process_payment_form($txn) { |
|
| 672 | + if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_memberpress_pay')) { |
|
| 673 | 673 | return false; |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | // Gateway. |
| 677 | 677 | $config_id = $this->settings->config_id; |
| 678 | 678 | |
| 679 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 679 | + $gateway = Plugin::get_gateway($config_id); |
|
| 680 | 680 | |
| 681 | - if ( $gateway ) { |
|
| 682 | - $this->payment_redirect( $txn ); |
|
| 681 | + if ($gateway) { |
|
| 682 | + $this->payment_redirect($txn); |
|
| 683 | 683 | } |
| 684 | 684 | } |
| 685 | 685 | |
@@ -707,20 +707,20 @@ discard block |
||
| 707 | 707 | * @param int $product_id Product ID. |
| 708 | 708 | * @param int $txn_id Transaction ID. |
| 709 | 709 | */ |
| 710 | - public function display_payment_form( $amount, $user, $product_id, $txn_id ) { |
|
| 711 | - $product = new MeprProduct( $product_id ); |
|
| 710 | + public function display_payment_form($amount, $user, $product_id, $txn_id) { |
|
| 711 | + $product = new MeprProduct($product_id); |
|
| 712 | 712 | |
| 713 | 713 | $coupon = false; |
| 714 | 714 | |
| 715 | - $txn = new MeprTransaction( $txn_id ); |
|
| 715 | + $txn = new MeprTransaction($txn_id); |
|
| 716 | 716 | |
| 717 | 717 | // Artifically set the price of the $prd in case a coupon was used. |
| 718 | - if ( $product->price !== $amount ) { |
|
| 718 | + if ($product->price !== $amount) { |
|
| 719 | 719 | $coupon = true; |
| 720 | 720 | $product->price = $amount; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - $invoice = MeprTransactionsHelper::get_invoice( $txn ); |
|
| 723 | + $invoice = MeprTransactionsHelper::get_invoice($txn); |
|
| 724 | 724 | |
| 725 | 725 | echo $invoice; // WPCS: XSS ok. |
| 726 | 726 | |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | <div class="mp_wrapper mp_payment_form_wrapper"> |
| 729 | 729 | <form action="" method="post" id="payment-form" class="mepr-form" novalidate> |
| 730 | 730 | <input type="hidden" name="mepr_process_payment_form" value="Y"/> |
| 731 | - <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/> |
|
| 731 | + <input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr($txn_id); ?>"/> |
|
| 732 | 732 | <input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/> |
| 733 | 733 | |
| 734 | 734 | <div class="mepr_spacer"> </div> |
@@ -738,9 +738,9 @@ discard block |
||
| 738 | 738 | // Gateway. |
| 739 | 739 | $config_id = $this->settings->config_id; |
| 740 | 740 | |
| 741 | - $gateway = Plugin::get_gateway( $config_id ); |
|
| 741 | + $gateway = Plugin::get_gateway($config_id); |
|
| 742 | 742 | |
| 743 | - if ( $gateway ) { |
|
| 743 | + if ($gateway) { |
|
| 744 | 744 | echo $gateway->get_input_html(); // WPCS: XSS ok. |
| 745 | 745 | } |
| 746 | 746 | |
@@ -748,13 +748,13 @@ discard block |
||
| 748 | 748 | |
| 749 | 749 | <div class="mepr_spacer"> </div> |
| 750 | 750 | |
| 751 | - <input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/> |
|
| 752 | - <img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 753 | - <?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?> |
|
| 751 | + <input type="submit" class="mepr-submit" value="<?php esc_attr_e('Pay', 'pronamic_ideal'); ?>"/> |
|
| 752 | + <img src="<?php echo esc_attr(admin_url('images/loading.gif')); ?>" style="display: none;" class="mepr-loading-gif"/> |
|
| 753 | + <?php MeprView::render('/shared/has_errors', get_defined_vars()); ?> |
|
| 754 | 754 | |
| 755 | 755 | <noscript> |
| 756 | 756 | <p class="mepr_nojs"> |
| 757 | - <?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' ); ?> |
|
| 757 | + <?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'); ?> |
|
| 758 | 758 | </p> |
| 759 | 759 | </noscript> |
| 760 | 760 | </form> |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | * @param array $errors Array with errors. |
| 773 | 773 | * @return array |
| 774 | 774 | */ |
| 775 | - public function validate_payment_form( $errors ) { |
|
| 775 | + public function validate_payment_form($errors) { |
|
| 776 | 776 | return $errors; |
| 777 | 777 | } |
| 778 | 778 | |
@@ -799,18 +799,18 @@ discard block |
||
| 799 | 799 | |
| 800 | 800 | ?> |
| 801 | 801 | <td> |
| 802 | - <?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?> |
|
| 802 | + <?php esc_html_e('Configuration', 'pronamic_ideal'); ?> |
|
| 803 | 803 | </td> |
| 804 | 804 | <td> |
| 805 | - <select name="<?php echo esc_attr( $name ); ?>"> |
|
| 805 | + <select name="<?php echo esc_attr($name); ?>"> |
|
| 806 | 806 | <?php |
| 807 | 807 | |
| 808 | - foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) { |
|
| 808 | + foreach (Plugin::get_config_select_options($this->payment_method) as $value => $label) { |
|
| 809 | 809 | printf( |
| 810 | 810 | '<option value="%s" %s>%s</option>', |
| 811 | - esc_attr( $value ), |
|
| 812 | - selected( $value, $this->settings->config_id, false ), |
|
| 813 | - esc_html( $label ) |
|
| 811 | + esc_attr($value), |
|
| 812 | + selected($value, $this->settings->config_id, false), |
|
| 813 | + esc_html($label) |
|
| 814 | 814 | ); |
| 815 | 815 | } |
| 816 | 816 | |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | * @param array $errors Array with errors. |
| 833 | 833 | * @return array |
| 834 | 834 | */ |
| 835 | - public function validate_options_form( $errors ) { |
|
| 835 | + public function validate_options_form($errors) { |
|
| 836 | 836 | return $errors; |
| 837 | 837 | } |
| 838 | 838 | |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168 |
| 858 | 858 | * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388 |
| 859 | 859 | */ |
| 860 | - public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) { |
|
| 860 | + public function display_update_account_form($sub_id, $errors = array(), $message = '') { |
|
| 861 | 861 | |
| 862 | 862 | } |
| 863 | 863 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | * @param array $errors Array with errors. |
| 871 | 871 | * @return array |
| 872 | 872 | */ |
| 873 | - public function validate_update_account_form( $errors = array() ) { |
|
| 873 | + public function validate_update_account_form($errors = array()) { |
|
| 874 | 874 | return $errors; |
| 875 | 875 | } |
| 876 | 876 | |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | * |
| 883 | 883 | * @param int $sub_id Subscription ID. |
| 884 | 884 | */ |
| 885 | - public function process_update_account_form( $sub_id ) { |
|
| 885 | + public function process_update_account_form($sub_id) { |
|
| 886 | 886 | |
| 887 | 887 | } |
| 888 | 888 | |
@@ -47,21 +47,21 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function __construct() { |
| 49 | 49 | // @see 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 118 | 118 | // @see 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |