@@ -8,4 +8,4 @@ |
||
8 | 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
9 | 9 | */ |
10 | 10 | |
11 | -class_alias( 'Pronamic\WordPress\Pay\Extensions\MemberPress\DirectDebitSofortGateway', 'MeprDirectDebitSofortGateway' ); |
|
11 | +class_alias('Pronamic\WordPress\Pay\Extensions\MemberPress\DirectDebitSofortGateway', 'MeprDirectDebitSofortGateway'); |
@@ -8,4 +8,4 @@ |
||
8 | 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
9 | 9 | */ |
10 | 10 | |
11 | -class_alias( 'Pronamic\WordPress\Pay\Extensions\MemberPress\Gateway', 'MeprPronamicGateway' ); |
|
11 | +class_alias('Pronamic\WordPress\Pay\Extensions\MemberPress\Gateway', 'MeprPronamicGateway'); |
@@ -8,4 +8,4 @@ |
||
8 | 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
9 | 9 | */ |
10 | 10 | |
11 | -class_alias( 'Pronamic\WordPress\Pay\Extensions\MemberPress\BankTransferGateway', 'MeprBankTransferGateway' ); |
|
11 | +class_alias('Pronamic\WordPress\Pay\Extensions\MemberPress\BankTransferGateway', 'MeprBankTransferGateway'); |
@@ -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 |
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: |
@@ -44,18 +44,18 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprGatewayFactory.php#L48-50 |
47 | - add_filter( 'mepr-gateway-paths', array( $this, 'gateway_paths' ) ); |
|
47 | + add_filter('mepr-gateway-paths', array($this, 'gateway_paths')); |
|
48 | 48 | |
49 | - add_filter( 'pronamic_payment_redirect_url_' . self::SLUG, array( __CLASS__, 'redirect_url' ), 10, 2 ); |
|
50 | - add_action( 'pronamic_payment_status_update_' . self::SLUG, array( __CLASS__, 'status_update' ), 10, 1 ); |
|
49 | + add_filter('pronamic_payment_redirect_url_' . self::SLUG, array(__CLASS__, 'redirect_url'), 10, 2); |
|
50 | + add_action('pronamic_payment_status_update_' . self::SLUG, array(__CLASS__, 'status_update'), 10, 1); |
|
51 | 51 | |
52 | - add_filter( 'pronamic_payment_source_text_' . self::SLUG, array( __CLASS__, 'source_text' ), 10, 2 ); |
|
53 | - add_filter( 'pronamic_payment_source_description_' . self::SLUG, array( __CLASS__, 'source_description' ), 10, 2 ); |
|
54 | - add_filter( 'pronamic_payment_source_url_' . self::SLUG, array( __CLASS__, 'source_url' ), 10, 2 ); |
|
52 | + add_filter('pronamic_payment_source_text_' . self::SLUG, array(__CLASS__, 'source_text'), 10, 2); |
|
53 | + add_filter('pronamic_payment_source_description_' . self::SLUG, array(__CLASS__, 'source_description'), 10, 2); |
|
54 | + add_filter('pronamic_payment_source_url_' . self::SLUG, array(__CLASS__, 'source_url'), 10, 2); |
|
55 | 55 | |
56 | - add_action( 'mepr_subscription_pre_delete', array( $this, 'subscription_pre_delete' ), 10, 1 ); |
|
56 | + add_action('mepr_subscription_pre_delete', array($this, 'subscription_pre_delete'), 10, 1); |
|
57 | 57 | |
58 | - add_action( 'mepr_subscription_transition_status', array( $this, 'memberpress_subscription_transition_status' ), 10, 3 ); |
|
58 | + add_action('mepr_subscription_transition_status', array($this, 'memberpress_subscription_transition_status'), 10, 3); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @param array $paths Array with gateway paths. |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public function gateway_paths( $paths ) { |
|
70 | - $paths[] = dirname( __FILE__ ) . '/../gateways/'; |
|
69 | + public function gateway_paths($paths) { |
|
70 | + $paths[] = dirname(__FILE__) . '/../gateways/'; |
|
71 | 71 | |
72 | 72 | return $paths; |
73 | 73 | } |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - public static function redirect_url( $url, Payment $payment ) { |
|
85 | + public static function redirect_url($url, Payment $payment) { |
|
86 | 86 | global $transaction; |
87 | 87 | |
88 | 88 | $transaction_id = $payment->get_source_id(); |
89 | 89 | |
90 | - $transaction = new MeprTransaction( $transaction_id ); |
|
90 | + $transaction = new MeprTransaction($transaction_id); |
|
91 | 91 | |
92 | - switch ( $payment->get_status() ) { |
|
92 | + switch ($payment->get_status()) { |
|
93 | 93 | case Statuses::CANCELLED: |
94 | 94 | case Statuses::EXPIRED: |
95 | 95 | case Statuses::FAILURE: |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | array( |
100 | 100 | 'action' => 'payment_form', |
101 | 101 | 'txn' => $transaction->trans_num, |
102 | - '_wpnonce' => wp_create_nonce( 'mepr_payment_form' ), |
|
102 | + '_wpnonce' => wp_create_nonce('mepr_payment_form'), |
|
103 | 103 | ), |
104 | 104 | $product->url() |
105 | 105 | ); |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | // @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L768-782 |
110 | 110 | $mepr_options = MeprOptions::fetch(); |
111 | 111 | |
112 | - $product = new MeprProduct( $transaction->product_id ); |
|
113 | - $sanitized_title = sanitize_title( $product->post_title ); |
|
112 | + $product = new MeprProduct($transaction->product_id); |
|
113 | + $sanitized_title = sanitize_title($product->post_title); |
|
114 | 114 | |
115 | 115 | $args = array( |
116 | 116 | 'membership_id' => $product->ID, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 'trans_num' => $transaction->trans_num, |
119 | 119 | ); |
120 | 120 | |
121 | - $url = $mepr_options->thankyou_page_url( http_build_query( $args ) ); |
|
121 | + $url = $mepr_options->thankyou_page_url(http_build_query($args)); |
|
122 | 122 | |
123 | 123 | break; |
124 | 124 | case Statuses::OPEN: |
@@ -136,22 +136,22 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @param Payment $payment The payment whose status is updated. |
138 | 138 | */ |
139 | - public static function status_update( Payment $payment ) { |
|
139 | + public static function status_update(Payment $payment) { |
|
140 | 140 | global $transaction; |
141 | 141 | |
142 | 142 | $transaction_id = $payment->get_source_id(); |
143 | 143 | |
144 | - $transaction = new MeprTransaction( $transaction_id ); |
|
144 | + $transaction = new MeprTransaction($transaction_id); |
|
145 | 145 | |
146 | - if ( $payment->get_recurring() ) { |
|
146 | + if ($payment->get_recurring()) { |
|
147 | 147 | $sub = $transaction->subscription(); |
148 | 148 | |
149 | 149 | // Same source ID and first transaction ID for recurring payment means we need to add a new transaction. |
150 | - if ( $payment->get_source_id() === $sub->first_txn_id ) { |
|
150 | + if ($payment->get_source_id() === $sub->first_txn_id) { |
|
151 | 151 | // First transaction. |
152 | 152 | $first_txn = $sub->first_txn(); |
153 | 153 | |
154 | - if ( false === $first_txn || ! ( $first_txn instanceof MeprTransaction ) ) { |
|
154 | + if (false === $first_txn || ! ($first_txn instanceof MeprTransaction)) { |
|
155 | 155 | $first_txn = new MeprTransaction(); |
156 | 156 | $first_txn->user_id = $sub->user_id; |
157 | 157 | $first_txn->product_id = $sub->product_id; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | // Transaction number. |
162 | 162 | $trans_num = $payment->get_transaction_id(); |
163 | 163 | |
164 | - if ( empty( $trans_num ) ) { |
|
164 | + if (empty($trans_num)) { |
|
165 | 165 | $trans_num = uniqid(); |
166 | 166 | } |
167 | 167 | |
@@ -177,27 +177,27 @@ discard block |
||
177 | 177 | $txn->status = MeprTransaction::$pending_str; |
178 | 178 | $txn->subscription_id = $sub->id; |
179 | 179 | |
180 | - $txn->set_gross( $payment->get_amount()->get_amount() ); |
|
180 | + $txn->set_gross($payment->get_amount()->get_amount()); |
|
181 | 181 | |
182 | 182 | $txn->store(); |
183 | 183 | |
184 | - update_post_meta( $payment->get_id(), '_pronamic_payment_source_id', $txn->id ); |
|
184 | + update_post_meta($payment->get_id(), '_pronamic_payment_source_id', $txn->id); |
|
185 | 185 | |
186 | 186 | $transaction = $txn; |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - $should_update = ! MemberPress::transaction_has_status( $transaction, array( |
|
190 | + $should_update = ! MemberPress::transaction_has_status($transaction, array( |
|
191 | 191 | MeprTransaction::$failed_str, |
192 | 192 | MeprTransaction::$complete_str, |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | |
195 | - if ( $should_update ) { |
|
195 | + if ($should_update) { |
|
196 | 196 | $gateway = new Gateway(); |
197 | 197 | |
198 | 198 | $gateway->mp_txn = $transaction; |
199 | 199 | |
200 | - switch ( $payment->get_status() ) { |
|
200 | + switch ($payment->get_status()) { |
|
201 | 201 | case Statuses::CANCELLED: |
202 | 202 | case Statuses::EXPIRED: |
203 | 203 | case Statuses::FAILURE: |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | break; |
207 | 207 | case Statuses::SUCCESS: |
208 | - if ( $payment->get_recurring() ) { |
|
208 | + if ($payment->get_recurring()) { |
|
209 | 209 | $gateway->record_subscription_payment(); |
210 | 210 | } else { |
211 | 211 | $gateway->record_payment(); |
@@ -224,25 +224,25 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param int $subscription_id MemberPress subscription id. |
226 | 226 | */ |
227 | - public function subscription_pre_delete( $subscription_id ) { |
|
228 | - $subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_memberpress_subscription_id', $subscription_id ); |
|
227 | + public function subscription_pre_delete($subscription_id) { |
|
228 | + $subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_memberpress_subscription_id', $subscription_id); |
|
229 | 229 | |
230 | - if ( ! $subscription ) { |
|
230 | + if ( ! $subscription) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | 234 | // Add note. |
235 | 235 | $note = sprintf( |
236 | 236 | /* translators: %s: MemberPress */ |
237 | - __( '%s subscription deleted.', 'pronamic_ideal' ), |
|
238 | - __( 'MemberPress', 'pronamic_ideal' ) |
|
237 | + __('%s subscription deleted.', 'pronamic_ideal'), |
|
238 | + __('MemberPress', 'pronamic_ideal') |
|
239 | 239 | ); |
240 | 240 | |
241 | - $subscription->add_note( $note ); |
|
241 | + $subscription->add_note($note); |
|
242 | 242 | |
243 | 243 | // The status of canceled or completed subscriptions will not be changed automatically. |
244 | - if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) { |
|
245 | - $subscription->set_status( Statuses::CANCELLED ); |
|
244 | + if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) { |
|
245 | + $subscription->set_status(Statuses::CANCELLED); |
|
246 | 246 | |
247 | 247 | $subscription->save(); |
248 | 248 | } |
@@ -256,18 +256,18 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return string |
258 | 258 | */ |
259 | - public static function source_text( $text, Payment $payment ) { |
|
260 | - $text = __( 'MemberPress', 'pronamic_ideal' ) . '<br />'; |
|
259 | + public static function source_text($text, Payment $payment) { |
|
260 | + $text = __('MemberPress', 'pronamic_ideal') . '<br />'; |
|
261 | 261 | |
262 | 262 | $text .= sprintf( |
263 | 263 | '<a href="%s">%s</a>', |
264 | - add_query_arg( array( |
|
264 | + add_query_arg(array( |
|
265 | 265 | 'page' => 'memberpress-trans', |
266 | 266 | 'action' => 'edit', |
267 | 267 | 'id' => $payment->source_id, |
268 | - ), admin_url( 'admin.php' ) ), |
|
268 | + ), admin_url('admin.php')), |
|
269 | 269 | /* translators: %s: payment source id */ |
270 | - sprintf( __( 'Transaction %s', 'pronamic_ideal' ), $payment->source_id ) |
|
270 | + sprintf(__('Transaction %s', 'pronamic_ideal'), $payment->source_id) |
|
271 | 271 | ); |
272 | 272 | |
273 | 273 | return $text; |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - public static function source_description( $description, Payment $payment ) { |
|
285 | - return __( 'MemberPress Transaction', 'pronamic_ideal' ); |
|
284 | + public static function source_description($description, Payment $payment) { |
|
285 | + return __('MemberPress Transaction', 'pronamic_ideal'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return string |
295 | 295 | */ |
296 | - public static function source_url( $url, Payment $payment ) { |
|
297 | - $url = add_query_arg( array( |
|
296 | + public static function source_url($url, Payment $payment) { |
|
297 | + $url = add_query_arg(array( |
|
298 | 298 | 'page' => 'memberpress-trans', |
299 | 299 | 'action' => 'edit', |
300 | 300 | 'id' => $payment->source_id, |
301 | - ), admin_url( 'admin.php' ) ); |
|
301 | + ), admin_url('admin.php')); |
|
302 | 302 | |
303 | 303 | return $url; |
304 | 304 | } |
@@ -314,16 +314,16 @@ discard block |
||
314 | 314 | * @param string $status_new New status identifier. |
315 | 315 | * @param MeprSubscription $memberpress_subscription MemberPress subscription object. |
316 | 316 | */ |
317 | - public function memberpress_subscription_transition_status( $status_old, $status_new, $memberpress_subscription ) { |
|
318 | - $pronamic_subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_memberpress_subscription_id', $memberpress_subscription->id ); |
|
317 | + public function memberpress_subscription_transition_status($status_old, $status_new, $memberpress_subscription) { |
|
318 | + $pronamic_subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_memberpress_subscription_id', $memberpress_subscription->id); |
|
319 | 319 | |
320 | - if ( empty( $pronamic_subscription ) ) { |
|
320 | + if (empty($pronamic_subscription)) { |
|
321 | 321 | return; |
322 | 322 | } |
323 | 323 | |
324 | - $pronamic_status = SubscriptionStatuses::transform( $status_new ); |
|
324 | + $pronamic_status = SubscriptionStatuses::transform($status_new); |
|
325 | 325 | |
326 | - $pronamic_subscription->set_status( $pronamic_status ); |
|
326 | + $pronamic_subscription->set_status($pronamic_status); |
|
327 | 327 | |
328 | 328 | $pronamic_subscription->save(); |
329 | 329 | } |