@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | *@return EE_Payment_Processor |
43 | 43 | */ |
44 | 44 | private function __construct() { |
45 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
45 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $update_txn = true, |
82 | 82 | $cancel_url = '' |
83 | 83 | ) { |
84 | - if( (float)$amount < 0 ) { |
|
84 | + if ((float) $amount < 0) { |
|
85 | 85 | throw new EE_Error( |
86 | 86 | sprintf( |
87 | 87 | __( |
@@ -94,33 +94,33 @@ discard block |
||
94 | 94 | ); |
95 | 95 | } |
96 | 96 | // verify payment method |
97 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
97 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
98 | 98 | // verify transaction |
99 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
100 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
99 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
100 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
101 | 101 | // verify payment method type |
102 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
102 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
103 | 103 | $payment = $payment_method->type_obj()->process_payment( |
104 | 104 | $transaction, |
105 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
105 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
106 | 106 | $billing_form, |
107 | 107 | $return_url, |
108 | - add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ), |
|
108 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
109 | 109 | $method, |
110 | 110 | $by_admin |
111 | 111 | ); |
112 | 112 | // check if payment method uses an off-site gateway |
113 | - if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) { |
|
113 | + if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) { |
|
114 | 114 | // don't process payments for off-site gateways yet because no payment has occurred yet |
115 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
115 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
116 | 116 | } |
117 | 117 | return $payment; |
118 | 118 | } else { |
119 | 119 | EE_Error::add_error( |
120 | 120 | sprintf( |
121 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
121 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
122 | 122 | '<br/>', |
123 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
123 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
124 | 124 | ), __FILE__, __FUNCTION__, __LINE__ |
125 | 125 | ); |
126 | 126 | return NULL; |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * @throws EE_Error |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
139 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
140 | 140 | /** @type \EE_Transaction $transaction */ |
141 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
141 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
142 | 142 | $primary_reg = $transaction->primary_registration(); |
143 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
143 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
144 | 144 | throw new EE_Error( |
145 | 145 | sprintf( |
146 | 146 | __( |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ) |
152 | 152 | ); |
153 | 153 | } |
154 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
154 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
155 | 155 | $url = add_query_arg( |
156 | 156 | array( |
157 | 157 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -188,92 +188,92 @@ discard block |
||
188 | 188 | $update_txn = true, |
189 | 189 | $separate_IPN_request = true |
190 | 190 | ) { |
191 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
192 | - $_req_data = $this->_remove_unusable_characters_from_array( (array)$_req_data ); |
|
193 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
191 | + EE_Registry::instance()->load_model('Change_Log'); |
|
192 | + $_req_data = $this->_remove_unusable_characters_from_array((array) $_req_data); |
|
193 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
194 | 194 | $obj_for_log = null; |
195 | - if( $transaction instanceof EE_Transaction ){ |
|
195 | + if ($transaction instanceof EE_Transaction) { |
|
196 | 196 | $obj_for_log = $transaction; |
197 | - if( $payment_method instanceof EE_Payment_Method ) { |
|
197 | + if ($payment_method instanceof EE_Payment_Method) { |
|
198 | 198 | $obj_for_log = EEM_Payment::instance()->get_one( |
199 | 199 | array( |
200 | - array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), |
|
201 | - 'order_by' => array( 'PAY_timestamp' => 'desc' ) |
|
200 | + array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), |
|
201 | + 'order_by' => array('PAY_timestamp' => 'desc') |
|
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | } |
205 | - } else if( $payment_method instanceof EE_Payment ) { |
|
205 | + } else if ($payment_method instanceof EE_Payment) { |
|
206 | 206 | $obj_for_log = $payment_method; |
207 | 207 | } |
208 | 208 | $log = EEM_Change_Log::instance()->log( |
209 | 209 | EEM_Change_Log::type_gateway, |
210 | - array( 'IPN data received' => $_req_data ), |
|
210 | + array('IPN data received' => $_req_data), |
|
211 | 211 | $obj_for_log |
212 | 212 | ); |
213 | - try{ |
|
213 | + try { |
|
214 | 214 | /** |
215 | 215 | * @var EE_Payment $payment |
216 | 216 | */ |
217 | 217 | $payment = NULL; |
218 | - if($transaction && $payment_method){ |
|
218 | + if ($transaction && $payment_method) { |
|
219 | 219 | /** @type EE_Transaction $transaction */ |
220 | 220 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
221 | 221 | /** @type EE_Payment_Method $payment_method */ |
222 | 222 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
223 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
224 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
223 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
224 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
225 | 225 | $log->set_object($payment); |
226 | 226 | } else { |
227 | 227 | // not a payment |
228 | 228 | EE_Error::add_error( |
229 | 229 | sprintf( |
230 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ), |
|
230 | + __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), |
|
231 | 231 | '<br/>', |
232 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
232 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
233 | 233 | ), |
234 | 234 | __FILE__, __FUNCTION__, __LINE__ |
235 | 235 | ); |
236 | 236 | } |
237 | - }else{ |
|
237 | + } else { |
|
238 | 238 | //that's actually pretty ok. The IPN just wasn't able |
239 | 239 | //to identify which transaction or payment method this was for |
240 | 240 | // give all active payment methods a chance to claim it |
241 | 241 | $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(); |
242 | - foreach( $active_payment_methods as $active_payment_method ){ |
|
243 | - try{ |
|
244 | - $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
242 | + foreach ($active_payment_methods as $active_payment_method) { |
|
243 | + try { |
|
244 | + $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
245 | 245 | $payment_method = $active_payment_method; |
246 | 246 | EEM_Change_Log::instance()->log( |
247 | 247 | EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment |
248 | 248 | ); |
249 | 249 | break; |
250 | - } catch( EE_Error $e ) { |
|
250 | + } catch (EE_Error $e) { |
|
251 | 251 | //that's fine- it apparently couldn't handle the IPN |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | } |
256 | 256 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
257 | - if( $payment instanceof EE_Payment){ |
|
257 | + if ($payment instanceof EE_Payment) { |
|
258 | 258 | $payment->save(); |
259 | 259 | // update the TXN |
260 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
261 | - }else{ |
|
260 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
261 | + } else { |
|
262 | 262 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
263 | - if($payment_method){ |
|
263 | + if ($payment_method) { |
|
264 | 264 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
265 | - }elseif($transaction){ |
|
265 | + }elseif ($transaction) { |
|
266 | 266 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | return $payment; |
270 | 270 | |
271 | - } catch( EE_Error $e ) { |
|
271 | + } catch (EE_Error $e) { |
|
272 | 272 | do_action( |
273 | 273 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
274 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
275 | - print_r( $transaction, TRUE ), |
|
276 | - print_r( $_req_data, TRUE ), |
|
274 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
275 | + print_r($transaction, TRUE), |
|
276 | + print_r($_req_data, TRUE), |
|
277 | 277 | $e->getMessage() |
278 | 278 | ) |
279 | 279 | ); |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @param array $request_data |
289 | 289 | * @return array |
290 | 290 | */ |
291 | - protected function _remove_unusable_characters_from_array( array $request_data ) { |
|
291 | + protected function _remove_unusable_characters_from_array(array $request_data) { |
|
292 | 292 | $return_data = array(); |
293 | - foreach( $request_data as $key => $value ) { |
|
294 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
293 | + foreach ($request_data as $key => $value) { |
|
294 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
295 | 295 | } |
296 | 296 | return $return_data; |
297 | 297 | } |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param string $request_data |
304 | 304 | * @return string |
305 | 305 | */ |
306 | - protected function _remove_unusable_characters( $request_data ) { |
|
307 | - return preg_replace( '/[^[:print:]]/', '', $request_data ); |
|
306 | + protected function _remove_unusable_characters($request_data) { |
|
307 | + return preg_replace('/[^[:print:]]/', '', $request_data); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, |
327 | 327 | * to call handle_ipn() for offsite gateways that don't receive separate IPNs |
328 | 328 | */ |
329 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
329 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
330 | 330 | /** @var $transaction EE_Transaction */ |
331 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
331 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
332 | 332 | $last_payment_method = $transaction->payment_method(); |
333 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
334 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
335 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
333 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
334 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
335 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
336 | 336 | return $payment; |
337 | 337 | } else { |
338 | 338 | return NULL; |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | EE_Payment $payment_to_refund, |
356 | 356 | $refund_info = array() |
357 | 357 | ) { |
358 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
359 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
360 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
358 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
359 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
360 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
361 | 361 | } |
362 | 362 | return $payment_to_refund; |
363 | 363 | } |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | * TXN is locked before updating |
399 | 399 | * @throws \EE_Error |
400 | 400 | */ |
401 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
401 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
402 | 402 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
403 | 403 | /** @type EE_Transaction $transaction */ |
404 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
404 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
405 | 405 | // can we freely update the TXN at this moment? |
406 | - if ( $IPN && $transaction->is_locked() ) { |
|
406 | + if ($IPN && $transaction->is_locked()) { |
|
407 | 407 | // don't update the transaction at this exact moment |
408 | 408 | // because the TXN is active in another request |
409 | 409 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -413,45 +413,45 @@ discard block |
||
413 | 413 | ); |
414 | 414 | } else { |
415 | 415 | // verify payment and that it has been saved |
416 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
417 | - if( |
|
416 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
417 | + if ( |
|
418 | 418 | $payment->payment_method() instanceof EE_Payment_Method |
419 | 419 | && $payment->payment_method()->type_obj() instanceof EE_PMT_Base |
420 | - ){ |
|
421 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
420 | + ) { |
|
421 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
422 | 422 | // update TXN registrations with payment info |
423 | - $this->process_registration_payments( $transaction, $payment ); |
|
423 | + $this->process_registration_payments($transaction, $payment); |
|
424 | 424 | } |
425 | 425 | $do_action = $payment->just_approved() |
426 | 426 | ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' |
427 | 427 | : $do_action; |
428 | 428 | } else { |
429 | 429 | // send out notifications |
430 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
430 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
431 | 431 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
432 | 432 | } |
433 | 433 | // if this is an IPN, then we want to know the initial TXN status prior to updating the TXN |
434 | 434 | // so that we know whether the status has changed and notifications should be triggered |
435 | - if ( $IPN ) { |
|
435 | + if ($IPN) { |
|
436 | 436 | /** @type EE_Transaction_Processor $transaction_processor */ |
437 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
438 | - $transaction_processor->set_old_txn_status( $transaction->status_ID() ); |
|
437 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
438 | + $transaction_processor->set_old_txn_status($transaction->status_ID()); |
|
439 | 439 | } |
440 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
440 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
441 | 441 | /** @type EE_Transaction_Payments $transaction_payments */ |
442 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
442 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
443 | 443 | // set new value for total paid |
444 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
444 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
445 | 445 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
446 | - if ( $update_txn ) { |
|
447 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
446 | + if ($update_txn) { |
|
447 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | // granular hook for others to use. |
451 | - do_action( $do_action, $transaction, $payment ); |
|
452 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
451 | + do_action($do_action, $transaction, $payment); |
|
452 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
453 | 453 | //global hook for others to use. |
454 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
454 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
@@ -471,25 +471,25 @@ discard block |
||
471 | 471 | $registrations = array() |
472 | 472 | ) { |
473 | 473 | // only process if payment was successful |
474 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
474 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
475 | 475 | return; |
476 | 476 | } |
477 | 477 | //EEM_Registration::instance()->show_next_x_db_queries(); |
478 | - if ( empty( $registrations )) { |
|
478 | + if (empty($registrations)) { |
|
479 | 479 | // find registrations with monies owing that can receive a payment |
480 | 480 | $registrations = $transaction->registrations( |
481 | 481 | array( |
482 | 482 | array( |
483 | 483 | // only these reg statuses can receive payments |
484 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
485 | - 'REG_final_price' => array( '!=', 0 ), |
|
486 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
484 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
485 | + 'REG_final_price' => array('!=', 0), |
|
486 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
487 | 487 | ) |
488 | 488 | ) |
489 | 489 | ); |
490 | 490 | } |
491 | 491 | // still nothing ??!?? |
492 | - if ( empty( $registrations )) { |
|
492 | + if (empty($registrations)) { |
|
493 | 493 | return; |
494 | 494 | } |
495 | 495 | // todo: break out the following logic into a separate strategy class |
@@ -501,28 +501,28 @@ discard block |
||
501 | 501 | |
502 | 502 | $refund = $payment->is_a_refund(); |
503 | 503 | // how much is available to apply to registrations? |
504 | - $available_payment_amount = abs( $payment->amount() ); |
|
505 | - foreach ( $registrations as $registration ) { |
|
506 | - if ( $registration instanceof EE_Registration ) { |
|
504 | + $available_payment_amount = abs($payment->amount()); |
|
505 | + foreach ($registrations as $registration) { |
|
506 | + if ($registration instanceof EE_Registration) { |
|
507 | 507 | // nothing left? |
508 | - if ( $available_payment_amount <= 0 ) { |
|
508 | + if ($available_payment_amount <= 0) { |
|
509 | 509 | break; |
510 | 510 | } |
511 | - if ( $refund ) { |
|
512 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
511 | + if ($refund) { |
|
512 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
513 | 513 | } else { |
514 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
514 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | } |
518 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
518 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
519 | 519 | EE_Error::add_attention( |
520 | 520 | sprintf( |
521 | - __( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ), |
|
522 | - EEH_Template::format_currency( $available_payment_amount ), |
|
523 | - implode( ', ', array_keys( $registrations ) ), |
|
521 | + __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), |
|
522 | + EEH_Template::format_currency($available_payment_amount), |
|
523 | + implode(', ', array_keys($registrations)), |
|
524 | 524 | '<br/>', |
525 | - EEH_Template::format_currency( $payment->amount() ) |
|
525 | + EEH_Template::format_currency($payment->amount()) |
|
526 | 526 | ), |
527 | 527 | __FILE__, __FUNCTION__, __LINE__ |
528 | 528 | ); |
@@ -540,17 +540,17 @@ discard block |
||
540 | 540 | * @return float |
541 | 541 | * @throws \EE_Error |
542 | 542 | */ |
543 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
543 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
544 | 544 | $owing = $registration->final_price() - $registration->paid(); |
545 | - if ( $owing > 0 ) { |
|
545 | + if ($owing > 0) { |
|
546 | 546 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
547 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
547 | + $payment_amount = min($available_payment_amount, $owing); |
|
548 | 548 | // update $available_payment_amount |
549 | 549 | $available_payment_amount -= $payment_amount; |
550 | 550 | //calculate and set new REG_paid |
551 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
551 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
552 | 552 | // now save it |
553 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
553 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
554 | 554 | } |
555 | 555 | return $available_payment_amount; |
556 | 556 | } |
@@ -566,19 +566,19 @@ discard block |
||
566 | 566 | * @return float |
567 | 567 | * @throws \EE_Error |
568 | 568 | */ |
569 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
569 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
570 | 570 | // find any existing reg payment records for this registration and payment |
571 | 571 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
572 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
572 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
573 | 573 | ); |
574 | 574 | // if existing registration payment exists |
575 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
575 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
576 | 576 | // then update that record |
577 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
577 | + $existing_reg_payment->set_amount($payment_amount); |
|
578 | 578 | $existing_reg_payment->save(); |
579 | 579 | } else { |
580 | 580 | // or add new relation between registration and payment and set amount |
581 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
581 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
582 | 582 | // make it stick |
583 | 583 | $registration->save(); |
584 | 584 | } |
@@ -595,21 +595,21 @@ discard block |
||
595 | 595 | * @return float |
596 | 596 | * @throws \EE_Error |
597 | 597 | */ |
598 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
598 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
599 | 599 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
600 | - if ( $registration->paid() > 0 ) { |
|
600 | + if ($registration->paid() > 0) { |
|
601 | 601 | // ensure $available_refund_amount is NOT negative |
602 | - $available_refund_amount = (float)abs( $available_refund_amount ); |
|
602 | + $available_refund_amount = (float) abs($available_refund_amount); |
|
603 | 603 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
604 | - $refund_amount = min( $available_refund_amount, (float)$registration->paid() ); |
|
604 | + $refund_amount = min($available_refund_amount, (float) $registration->paid()); |
|
605 | 605 | // update $available_payment_amount |
606 | 606 | $available_refund_amount -= $refund_amount; |
607 | 607 | //calculate and set new REG_paid |
608 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
608 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
609 | 609 | // convert payment amount back to a negative value for storage in the db |
610 | - $refund_amount = (float)abs( $refund_amount ) * -1; |
|
610 | + $refund_amount = (float) abs($refund_amount) * -1; |
|
611 | 611 | // now save it |
612 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
612 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
613 | 613 | } |
614 | 614 | return $available_refund_amount; |
615 | 615 | } |
@@ -628,21 +628,21 @@ discard block |
||
628 | 628 | * @param bool $IPN |
629 | 629 | * @throws \EE_Error |
630 | 630 | */ |
631 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
631 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
632 | 632 | |
633 | 633 | /** @type EE_Transaction_Processor $transaction_processor */ |
634 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
634 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
635 | 635 | // is the Payment Options Reg Step completed ? |
636 | - $payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' ); |
|
636 | + $payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options'); |
|
637 | 637 | // if the Payment Options Reg Step is completed... |
638 | 638 | $revisit = $payment_options_step_completed === true ? true : false; |
639 | 639 | // then this is kinda sorta a revisit with regards to payments at least |
640 | - $transaction_processor->set_revisit( $revisit ); |
|
640 | + $transaction_processor->set_revisit($revisit); |
|
641 | 641 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
642 | 642 | if ( |
643 | 643 | $IPN && |
644 | 644 | $payment_options_step_completed !== true && |
645 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
645 | + ($payment->is_approved() || $payment->is_pending()) |
|
646 | 646 | ) { |
647 | 647 | $payment_options_step_completed = $transaction_processor->set_reg_step_completed( |
648 | 648 | $transaction, |
@@ -650,34 +650,34 @@ discard block |
||
650 | 650 | ); |
651 | 651 | } |
652 | 652 | /** @type EE_Transaction_Payments $transaction_payments */ |
653 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
653 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
654 | 654 | // maybe update status, but don't save transaction just yet |
655 | - $transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false ); |
|
655 | + $transaction_payments->update_transaction_status_based_on_total_paid($transaction, false); |
|
656 | 656 | // check if 'finalize_registration' step has been completed... |
657 | - $finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' ); |
|
657 | + $finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration'); |
|
658 | 658 | // if this is an IPN and the final step has not been initiated |
659 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
659 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
660 | 660 | // and if it hasn't already been set as being started... |
661 | - $finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' ); |
|
661 | + $finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration'); |
|
662 | 662 | } |
663 | 663 | $transaction->save(); |
664 | 664 | // because the above will return false if the final step was not fully completed, we need to check again... |
665 | - if ( $IPN && $finalized !== false ) { |
|
665 | + if ($IPN && $finalized !== false) { |
|
666 | 666 | // and if we are all good to go, then send out notifications |
667 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
667 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
668 | 668 | //ok, now process the transaction according to the payment |
669 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
669 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
670 | 670 | } |
671 | 671 | // DEBUG LOG |
672 | 672 | $payment_method = $payment->payment_method(); |
673 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
673 | + if ($payment_method instanceof EE_Payment_Method) { |
|
674 | 674 | $payment_method_type_obj = $payment_method->type_obj(); |
675 | - if ( $payment_method_type_obj instanceof EE_PMT_Base ) { |
|
675 | + if ($payment_method_type_obj instanceof EE_PMT_Base) { |
|
676 | 676 | $gateway = $payment_method_type_obj->get_gateway(); |
677 | - if ( $gateway instanceof EE_Gateway ){ |
|
677 | + if ($gateway instanceof EE_Gateway) { |
|
678 | 678 | $gateway->log( |
679 | 679 | array( |
680 | - 'message' => __( 'Post Payment Transaction Details', 'event_espresso' ), |
|
680 | + 'message' => __('Post Payment Transaction Details', 'event_espresso'), |
|
681 | 681 | 'transaction' => $transaction->model_field_array(), |
682 | 682 | 'finalized' => $finalized, |
683 | 683 | 'IPN' => $IPN, |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class EE_Payment_Processor extends EE_Processor_Base { |
15 | 15 | /** |
16 | - * @var EE_Payment_Processor $_instance |
|
16 | + * @var EE_Payment_Processor $_instance |
|
17 | 17 | * @access private |
18 | - */ |
|
18 | + */ |
|
19 | 19 | private static $_instance; |
20 | 20 | |
21 | 21 | |
@@ -50,7 +50,6 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
52 | 52 | * Saves the payment that is generated |
53 | - |
|
54 | 53 | * |
55 | 54 | *@param EE_Payment_Method $payment_method |
56 | 55 | * @param EE_Transaction $transaction |
@@ -130,7 +129,6 @@ discard block |
||
130 | 129 | |
131 | 130 | |
132 | 131 | /** |
133 | - |
|
134 | 132 | * @param EE_Transaction|int $transaction |
135 | 133 | * @param EE_Payment_Method $payment_method |
136 | 134 | * @throws EE_Error |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Radio_Button_Display_Strategy |
4 | 4 | * displays a set of radio buttons |
@@ -15,34 +15,34 @@ discard block |
||
15 | 15 | * @throws EE_Error |
16 | 16 | * @return string of html to display the field |
17 | 17 | */ |
18 | - public function display(){ |
|
18 | + public function display() { |
|
19 | 19 | $input = $this->get_input(); |
20 | 20 | $input->set_label_sizes(); |
21 | 21 | $label_size_class = $input->get_label_size_class(); |
22 | 22 | $html = ''; |
23 | - foreach( $input->options() as $value => $display_text ){ |
|
24 | - $value = $input->get_normalization_strategy()->unnormalize( $value ); |
|
23 | + foreach ($input->options() as $value => $display_text) { |
|
24 | + $value = $input->get_normalization_strategy()->unnormalize($value); |
|
25 | 25 | |
26 | - $html_id = $this->get_sub_input_id( $value ); |
|
27 | - $html .= EEH_HTML::nl( 0, 'radio' ); |
|
28 | - $html .= '<label for="' . $html_id . '"'; |
|
29 | - $html .= ' id="' . $html_id . '-lbl"'; |
|
30 | - $html .= ' class="ee-radio-label-after' . $label_size_class . '">'; |
|
31 | - $html .= EEH_HTML::nl( 1, 'radio' ); |
|
32 | - $html .= '<input id="' . $html_id . '"'; |
|
33 | - $html .= ' name="' . $input->html_name() . '"'; |
|
34 | - $html .= ' class="' . $input->html_class() . '"'; |
|
35 | - $html .= ' style="' . $input->html_style() . '"'; |
|
26 | + $html_id = $this->get_sub_input_id($value); |
|
27 | + $html .= EEH_HTML::nl(0, 'radio'); |
|
28 | + $html .= '<label for="'.$html_id.'"'; |
|
29 | + $html .= ' id="'.$html_id.'-lbl"'; |
|
30 | + $html .= ' class="ee-radio-label-after'.$label_size_class.'">'; |
|
31 | + $html .= EEH_HTML::nl(1, 'radio'); |
|
32 | + $html .= '<input id="'.$html_id.'"'; |
|
33 | + $html .= ' name="'.$input->html_name().'"'; |
|
34 | + $html .= ' class="'.$input->html_class().'"'; |
|
35 | + $html .= ' style="'.$input->html_style().'"'; |
|
36 | 36 | $html .= ' type="radio"'; |
37 | - $html .= ' value="' . esc_attr( $value ) . '"'; |
|
37 | + $html .= ' value="'.esc_attr($value).'"'; |
|
38 | 38 | $html .= $input->raw_value() === $value ? ' checked="checked"' : ''; |
39 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
39 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
40 | 40 | $html .= '> '; |
41 | 41 | $html .= $display_text; |
42 | - $html .= EEH_HTML::nl( -1, 'radio' ) . '</label>'; |
|
42 | + $html .= EEH_HTML::nl( -1, 'radio' ).'</label>'; |
|
43 | 43 | |
44 | 44 | } |
45 | - $html .= EEH_HTML::div( '', '', 'clear-float' ); |
|
45 | + $html .= EEH_HTML::div('', '', 'clear-float'); |
|
46 | 46 | $html .= EEH_HTML::divx(); |
47 | 47 | return $html; |
48 | 48 | } |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * @param WP $WP |
51 | 51 | * @return void |
52 | 52 | */ |
53 | - public function run( WP $WP ) { |
|
54 | - if ( did_action( 'pre_get_posts' ) && did_action( 'send_headers' ) ) { |
|
53 | + public function run(WP $WP) { |
|
54 | + if (did_action('pre_get_posts') && did_action('send_headers')) { |
|
55 | 55 | EED_Events_Archive::instance()->event_list(); |
56 | 56 | } else { |
57 | 57 | // this will trigger the EED_Events_Archive module's event_list() method during the pre_get_posts hook point, |
58 | 58 | // this allows us to initialize things, enqueue assets, etc, |
59 | 59 | // as well, this saves an instantiation of the module in an array using 'espresso_events' as the key, so that we can retrieve it |
60 | - add_action( 'pre_get_posts', array( EED_Events_Archive::instance(), 'event_list' ) ); |
|
60 | + add_action('pre_get_posts', array(EED_Events_Archive::instance(), 'event_list')); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @param array $attributes |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - public function process_shortcode( $attributes = array() ) { |
|
82 | + public function process_shortcode($attributes = array()) { |
|
83 | 83 | // make sure EED_Events_Archive is setup properly |
84 | - if ( apply_filters( 'FHEE__fallback_shortcode_processor__EES_Espresso_Events', FALSE )) { |
|
84 | + if (apply_filters('FHEE__fallback_shortcode_processor__EES_Espresso_Events', FALSE)) { |
|
85 | 85 | EED_Events_Archive::instance()->event_list(); |
86 | 86 | } |
87 | 87 | //set default attributes |
@@ -102,24 +102,24 @@ discard block |
||
102 | 102 | $default_espresso_events_shortcode_atts |
103 | 103 | ); |
104 | 104 | // grab attributes and merge with defaults, then extract |
105 | - $attributes = array_merge( (array) $default_espresso_events_shortcode_atts, (array) $attributes ); |
|
105 | + $attributes = array_merge((array) $default_espresso_events_shortcode_atts, (array) $attributes); |
|
106 | 106 | // make sure we use the_excerpt() |
107 | - add_filter( 'FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true' ); |
|
107 | + add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
108 | 108 | // apply query filters |
109 | - add_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' ); |
|
109 | + add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
110 | 110 | // run the query |
111 | 111 | global $wp_query; |
112 | - $wp_query = new EE_Event_List_Query( $attributes ); |
|
112 | + $wp_query = new EE_Event_List_Query($attributes); |
|
113 | 113 | // check what template is loaded and load filters accordingly |
114 | - EED_Events_Archive::instance()->template_include( 'loop-espresso_events.php' ); |
|
114 | + EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
115 | 115 | // load our template |
116 | - $event_list = EEH_Template::locate_template( 'loop-espresso_events.php', array(), TRUE, TRUE ); |
|
116 | + $event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), TRUE, TRUE); |
|
117 | 117 | // now reset the query and postdata |
118 | 118 | wp_reset_query(); |
119 | 119 | wp_reset_postdata(); |
120 | 120 | EED_Events_Archive::remove_all_events_archive_filters(); |
121 | 121 | // remove query filters |
122 | - remove_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' ); |
|
122 | + remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
123 | 123 | // pull our content from the output buffer and return it |
124 | 124 | return $event_list; |
125 | 125 | } |
@@ -164,44 +164,44 @@ discard block |
||
164 | 164 | * @param array $args |
165 | 165 | * @return \EE_Event_List_Query |
166 | 166 | */ |
167 | - function __construct( $args = array() ) { |
|
167 | + function __construct($args = array()) { |
|
168 | 168 | // EEH_Debug_Tools::printr( $args, '$args <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
169 | 169 | // incoming args could be a mix of WP query args + EE shortcode args |
170 | - foreach ( $args as $key =>$value ) { |
|
171 | - $property = '_' . $key; |
|
170 | + foreach ($args as $key =>$value) { |
|
171 | + $property = '_'.$key; |
|
172 | 172 | // if the arg is a property of this class, then it's an EE shortcode arg |
173 | - if ( property_exists( $this, $property )) { |
|
173 | + if (property_exists($this, $property)) { |
|
174 | 174 | // set the property value |
175 | 175 | $this->{$property} = $value; |
176 | 176 | // then remove it from the array of args that will later be passed to WP_Query() |
177 | - unset( $args[ $key ] ); |
|
177 | + unset($args[$key]); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | //add query filters |
181 | 181 | EEH_Event_Query::add_query_filters(); |
182 | 182 | // set params that will get used by the filters |
183 | - EEH_Event_Query::set_query_params( $this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort ); |
|
183 | + EEH_Event_Query::set_query_params($this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort); |
|
184 | 184 | // first off, let's remove any filters from previous queries |
185 | - remove_filter( 'FHEE__archive_espresso_events_template__upcoming_events_h1', array( $this, 'event_list_title' )); |
|
186 | - remove_all_filters( 'FHEE__content_espresso_events__event_class' ); |
|
185 | + remove_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title')); |
|
186 | + remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
187 | 187 | // Event List Title ? |
188 | - add_filter( 'FHEE__archive_espresso_events_template__upcoming_events_h1', array( $this, 'event_list_title' ), 10, 1 ); |
|
188 | + add_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'), 10, 1); |
|
189 | 189 | // add the css class |
190 | - add_filter( 'FHEE__content_espresso_events__event_class', array( $this, 'event_list_css' ), 10, 1 ); |
|
190 | + add_filter('FHEE__content_espresso_events__event_class', array($this, 'event_list_css'), 10, 1); |
|
191 | 191 | // the current "page" we are viewing |
192 | - $paged = max( 1, get_query_var( 'paged' )); |
|
192 | + $paged = max(1, get_query_var('paged')); |
|
193 | 193 | // Force these args |
194 | - $args = array_merge( $args, array( |
|
194 | + $args = array_merge($args, array( |
|
195 | 195 | 'post_type' => 'espresso_events', |
196 | 196 | 'posts_per_page' => $this->_limit, |
197 | 197 | 'update_post_term_cache' => FALSE, |
198 | 198 | 'update_post_meta_cache' => FALSE, |
199 | 199 | 'paged' => $paged, |
200 | - 'offset' => ( $paged - 1 ) * $this->_limit |
|
200 | + 'offset' => ($paged - 1) * $this->_limit |
|
201 | 201 | )); |
202 | 202 | |
203 | 203 | // run the query |
204 | - parent::__construct( $args ); |
|
204 | + parent::__construct($args); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | * @param string $event_list_title |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - public function event_list_title( $event_list_title = '' ) { |
|
218 | - if ( ! empty( $this->_title )) { |
|
217 | + public function event_list_title($event_list_title = '') { |
|
218 | + if ( ! empty($this->_title)) { |
|
219 | 219 | return $this->_title; |
220 | 220 | } |
221 | 221 | return $event_list_title; |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | * @param string $event_list_css |
231 | 231 | * @return array |
232 | 232 | */ |
233 | - public function event_list_css( $event_list_css = '' ) { |
|
234 | - $event_list_css .= ! empty( $event_list_css ) ? ' ' : ''; |
|
235 | - $event_list_css .= ! empty( $this->_css_class ) ? $this->_css_class : ''; |
|
236 | - $event_list_css .= ! empty( $event_list_css ) ? ' ' : ''; |
|
237 | - $event_list_css .= ! empty( $this->_category_slug ) ? $this->_category_slug : ''; |
|
233 | + public function event_list_css($event_list_css = '') { |
|
234 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
235 | + $event_list_css .= ! empty($this->_css_class) ? $this->_css_class : ''; |
|
236 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
237 | + $event_list_css .= ! empty($this->_category_slug) ? $this->_category_slug : ''; |
|
238 | 238 | return $event_list_css; |
239 | 239 | } |
240 | 240 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @author Mike Nelson |
20 | 20 | * |
21 | 21 | */ |
22 | -class EED_Mijireh_Payment_Checker extends EED_Module{ |
|
22 | +class EED_Mijireh_Payment_Checker extends EED_Module { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * set_hooks - for hooking into EE Core, other modules, etc |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * @return void |
41 | 41 | */ |
42 | 42 | public static function set_hooks_admin() { |
43 | - add_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', array( 'EED_Mijireh_Payment_Checker', 'check_for_payment_update_on_transaction' ), 10, 1 ); |
|
43 | + add_action('AHEE__Transactions_Admin_Page__transaction_details__start', array('EED_Mijireh_Payment_Checker', 'check_for_payment_update_on_transaction'), 10, 1); |
|
44 | 44 | } |
45 | 45 | |
46 | - public static function check_for_payment_update_on_transaction( $transaction ) { |
|
47 | - if( $transaction instanceof EE_Transaction ) { |
|
46 | + public static function check_for_payment_update_on_transaction($transaction) { |
|
47 | + if ($transaction instanceof EE_Transaction) { |
|
48 | 48 | $last_payment = $transaction->last_payment(); |
49 | 49 | //if this payment is from Mijireh and so far unapproved |
50 | - if( |
|
50 | + if ( |
|
51 | 51 | $last_payment instanceof EE_Payment && |
52 | 52 | $last_payment->payment_method() instanceof EE_Payment_Method && |
53 | 53 | $last_payment->payment_method()->type_obj() instanceof EE_PMT_Mijireh && |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | ) { |
56 | 56 | add_action( |
57 | 57 | 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
58 | - array( 'EED_Mijireh_Payment_Checker', 'send_notifications_after_mijireh_ipn' ), |
|
58 | + array('EED_Mijireh_Payment_Checker', 'send_notifications_after_mijireh_ipn'), |
|
59 | 59 | 5, 2 |
60 | 60 | ); |
61 | - EE_Payment_Processor::instance()->process_ipn( array(), $transaction, $last_payment->payment_method() ); |
|
61 | + EE_Payment_Processor::instance()->process_ipn(array(), $transaction, $last_payment->payment_method()); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * @param EE_Registration $registration |
75 | 75 | * @param array $additional_details |
76 | 76 | */ |
77 | - public static function send_notifications_after_mijireh_ipn( $registration, $additional_details ) { |
|
78 | - $last_payment = isset( $additional_details[ 'last_payment' ] ) ? $additional_details[ 'last_payment' ] : null; |
|
79 | - if ( ! $last_payment instanceof EE_Payment || $last_payment->status() != EEM_Payment::status_id_approved ) { |
|
80 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 ); |
|
77 | + public static function send_notifications_after_mijireh_ipn($registration, $additional_details) { |
|
78 | + $last_payment = isset($additional_details['last_payment']) ? $additional_details['last_payment'] : null; |
|
79 | + if ( ! $last_payment instanceof EE_Payment || $last_payment->status() != EEM_Payment::status_id_approved) { |
|
80 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @access public |
90 | 90 | * @param WP_Query $WP_Query |
91 | 91 | */ |
92 | - public function run( $WP_Query = null ) { |
|
92 | + public function run($WP_Query = null) { |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | /** |
6 | 6 | * Event Espresso |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | <li><?php printf( |
40 | 40 | __('To find the sandbox account\'s credit card, go to %1$s, then "Dashboard", then under Sandbox click "Accounts", then click your account and click "Profile", then in the popup that appears click on the "Funding" tab. Your testing card is listed there.', 'event_espresso'), |
41 | 41 | '<a href="http://developer.paypal.com">developer.paypal.com</a>'); ?></li> |
42 | - <li><?php printf(__('CVV2 should be 115 (see %s PayPal\'s documentation for other special codes %s)', 'event_espresso'),'<a href="https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_testing_SBTestErrorConditions#id108HH0RJ0TS" target="_blank">','</a>'); ?></li> |
|
42 | + <li><?php printf(__('CVV2 should be 115 (see %s PayPal\'s documentation for other special codes %s)', 'event_espresso'), '<a href="https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_testing_SBTestErrorConditions#id108HH0RJ0TS" target="_blank">', '</a>'); ?></li> |
|
43 | 43 | </ul> |
44 | 44 | |
45 | 45 | <p class="test-credit-cards-info-pg"> |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | <p class="test-credit-cards-info-pg"> |
68 | 68 | <strong><?php _e('Testing Result Code Responses', 'event_espresso'); ?></strong><br/> |
69 | - <span class="small-text"><?php printf(__('You can use the amount of the transaction to generate a particular result code (see %s PayPal\'s documentation%s). The table below lists the general guidelines for specifying amounts. IMPORTANT: before you attempt any of these, ensure your sandbox PayPal account has %s "Negative Testing" set to on%s. Also be aware that you can generate AVS errors by using certain strings in your address field, and CVV errors using certain CVV values. See %s this PayPal doc %s', 'event_espresso'),"<a href='https://developer.paypal.com/docs/classic/api/errorcodes/#id09C3GA00GR1' target='_blank'>","</a>", "<a href='https://docs.google.com/a/eventespresso.com/file/d/0B5P8GXTvZgfMNXNkZ2s5VUlHTUk/edit?usp=drivesdk' target='_blank'>","</a>","<a href='https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_testing_SBTestErrorConditions' target='_blank'>","</a>"); ?></span> |
|
69 | + <span class="small-text"><?php printf(__('You can use the amount of the transaction to generate a particular result code (see %s PayPal\'s documentation%s). The table below lists the general guidelines for specifying amounts. IMPORTANT: before you attempt any of these, ensure your sandbox PayPal account has %s "Negative Testing" set to on%s. Also be aware that you can generate AVS errors by using certain strings in your address field, and CVV errors using certain CVV values. See %s this PayPal doc %s', 'event_espresso'), "<a href='https://developer.paypal.com/docs/classic/api/errorcodes/#id09C3GA00GR1' target='_blank'>", "</a>", "<a href='https://docs.google.com/a/eventespresso.com/file/d/0B5P8GXTvZgfMNXNkZ2s5VUlHTUk/edit?usp=drivesdk' target='_blank'>", "</a>", "<a href='https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_testing_SBTestErrorConditions' target='_blank'>", "</a>"); ?></span> |
|
70 | 70 | </p> |
71 | 71 | |
72 | 72 | <div class="tbl-wrap"> |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | /** |
6 | 7 | * Event Espresso |
7 | 8 | * |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | $this->description = __('All shortcodes related to emails', 'event_espresso'); |
44 | 44 | $this->_shortcodes = array( |
45 | 45 | '[SITE_ADMIN_EMAIL]' => __('Will be replaced with the admin email for the site that Event Espresso is installed on', 'event_espresso'), |
46 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' => __('This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', 'event_espresso'),'<strong>','</strong>', |
|
46 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' => __('This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', 'event_espresso'), '<strong>', '</strong>', |
|
47 | 47 | '[EVENT_AUTHOR_EMAIL]' => __('This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', 'event_espresso'), '[EVENT_AUTHOR_FORMATTED_EMAIL]', |
48 | - '[CO_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso' ), |
|
48 | + '[CO_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso'), |
|
49 | 49 | '[CO_EMAIL]' => __('This will parse to the email address only for the organization set in Your Organization Settings.', 'event_espresso'), |
50 | - '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso' ), |
|
50 | + '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso'), |
|
51 | 51 | '[ESPRESSO_ADMIN_EMAIL]' => __('This parses to the email address only for the organization set in Your Organization Settings page.', 'event_espresso') |
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | - protected function _parser( $shortcode ) { |
|
56 | + protected function _parser($shortcode) { |
|
57 | 57 | |
58 | - switch ( $shortcode ) { |
|
58 | + switch ($shortcode) { |
|
59 | 59 | |
60 | 60 | case '[SITE_ADMIN_EMAIL]' : |
61 | 61 | return $this->_get_site_admin_email(); |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | break; |
67 | 67 | |
68 | 68 | case '[EVENT_AUTHOR_EMAIL]' : |
69 | - return $this->_get_event_admin_emails( FALSE ); |
|
69 | + return $this->_get_event_admin_emails(FALSE); |
|
70 | 70 | break; |
71 | 71 | |
72 | 72 | case '[CO_FORMATTED_EMAIL]' : |
73 | 73 | case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' : |
74 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) . '>'; |
|
74 | + return EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.EE_Registry::instance()->CFG->organization->get_pretty('email').'>'; |
|
75 | 75 | break; |
76 | 76 | |
77 | 77 | case '[CO_EMAIL]' : |
78 | 78 | case '[ESPRESSO_ADMIN_EMAIL]' : |
79 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
79 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | default : |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | - private function _get_event_admin_emails( $fancy_headers = TRUE ) { |
|
101 | + private function _get_event_admin_emails($fancy_headers = TRUE) { |
|
102 | 102 | |
103 | - if ( !empty( $this->_data->admin_email ) ) { |
|
104 | - if ( ! $fancy_headers ) |
|
103 | + if ( ! empty($this->_data->admin_email)) { |
|
104 | + if ( ! $fancy_headers) |
|
105 | 105 | return $this->_data->admin_email; |
106 | - return !empty( $this->_data->fname ) ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' : EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . $this->_data->admin_email . '>'; |
|
106 | + return ! empty($this->_data->fname) ? $this->_data->fname.' '.$this->_data->lname.' <'.$this->_data->admin_email.'>' : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$this->_data->admin_email.'>'; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | //k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | $admin_email = array(); |
112 | 112 | |
113 | 113 | //loop through events and set the list of event_ids to retrieve so we can do ONE query. |
114 | - foreach ( $this->_data->events as $event ) { |
|
114 | + foreach ($this->_data->events as $event) { |
|
115 | 115 | $ids[] = $event['ID']; |
116 | 116 | } |
117 | 117 | |
118 | 118 | //get all the events |
119 | - $events = EE_Registry::instance()->load_model('Event')->get_all( array(array('EVT_ID' => array('IN', $ids ) ) ) ); |
|
119 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids)))); |
|
120 | 120 | |
121 | 121 | //now loop through each event and setup the details |
122 | 122 | $admin_details = array(); |
123 | 123 | $cnt = 0; |
124 | - foreach ( $events as $event ) { |
|
125 | - $user = get_userdata($event->get('EVT_wp_user') ); |
|
124 | + foreach ($events as $event) { |
|
125 | + $user = get_userdata($event->get('EVT_wp_user')); |
|
126 | 126 | $admin_details[$cnt] = new stdClass(); |
127 | 127 | $admin_details[$cnt]->email = $user->user_email; |
128 | 128 | $admin_details[$cnt]->first_name = $user->user_firstname; |
@@ -131,28 +131,28 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | //results? |
134 | - if ( empty($admin_details) || !is_array($admin_details) ) { |
|
134 | + if (empty($admin_details) || ! is_array($admin_details)) { |
|
135 | 135 | $msg[] = __('The admin details could not be retrieved from the database.', 'event_espresso'); |
136 | - $msg[] = sprintf( __('Query: %s', 'event_espresso'), $sql ); |
|
137 | - $msg[] = sprintf( __('Events Data: %s', 'event_espresso'), var_export($this->_data->events, TRUE) ); |
|
138 | - $msg[] = sprintf( __('Event IDS: %s', 'event_espresso'), var_export($ids, TRUE) ); |
|
139 | - $msg[] = sprintf( __('Query Results: %s', 'event_espresso'), var_export($admin_details) ); |
|
140 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, implode( PHP_EOL, $msg ), 'shortcode_parser' ); |
|
136 | + $msg[] = sprintf(__('Query: %s', 'event_espresso'), $sql); |
|
137 | + $msg[] = sprintf(__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, TRUE)); |
|
138 | + $msg[] = sprintf(__('Event IDS: %s', 'event_espresso'), var_export($ids, TRUE)); |
|
139 | + $msg[] = sprintf(__('Query Results: %s', 'event_espresso'), var_export($admin_details)); |
|
140 | + do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser'); |
|
141 | 141 | } |
142 | 142 | |
143 | - foreach ( $admin_details as $admin ) { |
|
143 | + foreach ($admin_details as $admin) { |
|
144 | 144 | //only add an admin email if it is present. |
145 | - if ( empty( $admin->email ) || $admin->email == '' ) continue; |
|
145 | + if (empty($admin->email) || $admin->email == '') continue; |
|
146 | 146 | |
147 | - if ( ! $fancy_headers ) { |
|
147 | + if ( ! $fancy_headers) { |
|
148 | 148 | $admin_email[] = $admin->email; |
149 | 149 | continue; |
150 | 150 | } |
151 | 151 | |
152 | - $admin_email[] = !empty( $admin->first_name ) ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' : EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . $admin->email . '>'; |
|
152 | + $admin_email[] = ! empty($admin->first_name) ? $admin->first_name.' '.$admin->last_name.' <'.$admin->email.'>' : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$admin->email.'>'; |
|
153 | 153 | } |
154 | 154 | |
155 | - $admin_email = implode( ',', $admin_email ); |
|
155 | + $admin_email = implode(',', $admin_email); |
|
156 | 156 | return $admin_email; |
157 | 157 | } |
158 | 158 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -58,96 +58,96 @@ discard block |
||
58 | 58 | '[CO_GOOGLE_URL]' => __('Link to organization Google page', 'event_espresso'), |
59 | 59 | '[CO_LINKEDIN_URL]' => __('Link to organization LinkedIn page', 'event_espresso'), |
60 | 60 | '[CO_INSTAGRAM_URL]' => __('Link to organization Instagram page', 'event_espresso'), |
61 | - '[CO_TAX_NUMBER_*]' => __('This is the shortcode used for displaying any tax number for the company. %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56. Also take note that if you have NO number in your settings, the prefix is not output either.', 'event_espresso','<strong>','</strong>') |
|
61 | + '[CO_TAX_NUMBER_*]' => __('This is the shortcode used for displaying any tax number for the company. %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56. Also take note that if you have NO number in your settings, the prefix is not output either.', 'event_espresso', '<strong>', '</strong>') |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
65 | 65 | |
66 | - protected function _parser( $shortcode ) { |
|
66 | + protected function _parser($shortcode) { |
|
67 | 67 | |
68 | - switch ( $shortcode ) { |
|
68 | + switch ($shortcode) { |
|
69 | 69 | |
70 | 70 | case '[COMPANY]' : |
71 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
71 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
72 | 72 | break; |
73 | 73 | |
74 | 74 | case '[CO_ADD1]' : |
75 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'address_1' ); |
|
75 | + return EE_Registry::instance()->CFG->organization->get_pretty('address_1'); |
|
76 | 76 | break; |
77 | 77 | |
78 | 78 | case '[CO_ADD2]' : |
79 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'address_2' ); |
|
79 | + return EE_Registry::instance()->CFG->organization->get_pretty('address_2'); |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | case '[CO_CITY]' : |
83 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'city' ); |
|
83 | + return EE_Registry::instance()->CFG->organization->get_pretty('city'); |
|
84 | 84 | break; |
85 | 85 | |
86 | 86 | case '[CO_STATE]' : |
87 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( EE_Registry::instance()->CFG->organization->STA_ID ); |
|
87 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID(EE_Registry::instance()->CFG->organization->STA_ID); |
|
88 | 88 | return $state->name(); |
89 | 89 | break; |
90 | 90 | |
91 | 91 | case '[CO_ZIP]' : |
92 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'zip' ); |
|
92 | + return EE_Registry::instance()->CFG->organization->get_pretty('zip'); |
|
93 | 93 | break; |
94 | 94 | |
95 | 95 | case '[CO_EMAIL]' : |
96 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
96 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
97 | 97 | break; |
98 | 98 | |
99 | 99 | case '[CO_PHONE]' : |
100 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'phone' ); |
|
100 | + return EE_Registry::instance()->CFG->organization->get_pretty('phone'); |
|
101 | 101 | break; |
102 | 102 | |
103 | 103 | case '[CO_LOGO]' : |
104 | - return '<img src="' . EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ) . '" id="headerImage" />'; |
|
104 | + return '<img src="'.EE_Registry::instance()->CFG->organization->get_pretty('logo_url').'" id="headerImage" />'; |
|
105 | 105 | break; |
106 | 106 | |
107 | 107 | case '[CO_LOGO_URL]' : |
108 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
108 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
109 | 109 | break; |
110 | 110 | |
111 | 111 | case '[CO_FACEBOOK_URL]' : |
112 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
112 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
113 | 113 | break; |
114 | 114 | |
115 | 115 | case '[CO_TWITTER_URL]' : |
116 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
116 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
117 | 117 | break; |
118 | 118 | |
119 | 119 | case '[CO_PINTEREST_URL]' : |
120 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
120 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
121 | 121 | break; |
122 | 122 | |
123 | 123 | case '[CO_LINKEDIN_URL]' : |
124 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
124 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
125 | 125 | break; |
126 | 126 | |
127 | 127 | case '[CO_GOOGLE_URL]' : |
128 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
128 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | case '[CO_INSTAGRAM_URL]' : |
132 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
132 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
133 | 133 | break; |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | 137 | //also allow for parameter shortcode |
138 | - if ( strpos( $shortcode, '[CO_TAX_NUMBER_*' ) !== FALSE ) { |
|
138 | + if (strpos($shortcode, '[CO_TAX_NUMBER_*') !== FALSE) { |
|
139 | 139 | //first see if there is any company tax number set and bail early if not |
140 | 140 | $tax_number = EE_Registry::instance()->CFG->organization->vat; |
141 | - if ( empty( $tax_number ) ) { |
|
141 | + if (empty($tax_number)) { |
|
142 | 142 | return ''; |
143 | 143 | } |
144 | 144 | |
145 | 145 | //see if there are any attributes. |
146 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
146 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
147 | 147 | |
148 | 148 | //set custom attrs if present (or default) |
149 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso'); |
|
150 | - return $prefix . $tax_number; |
|
149 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso'); |
|
150 | + return $prefix.$tax_number; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return ''; |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -18,43 +18,43 @@ |
||
18 | 18 | * @throws EE_Error |
19 | 19 | * @return string of html to display the field |
20 | 20 | */ |
21 | - public function display(){ |
|
21 | + public function display() { |
|
22 | 22 | $input = $this->get_input(); |
23 | 23 | //d( $input ); |
24 | - $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
24 | + $multi = count($input->options()) > 1 ? TRUE : FALSE; |
|
25 | 25 | $input->set_label_sizes(); |
26 | 26 | $label_size_class = $input->get_label_size_class(); |
27 | 27 | $html = ''; |
28 | - if ( ! is_array( $input->raw_value() ) && $input->raw_value() !== NULL ) { |
|
28 | + if ( ! is_array($input->raw_value()) && $input->raw_value() !== NULL) { |
|
29 | 29 | EE_Error::doing_it_wrong( |
30 | 30 | 'EE_Checkbox_Display_Strategy::display()', |
31 | 31 | sprintf( |
32 | - __( 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'), |
|
32 | + __('Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'), |
|
33 | 33 | $input->html_id(), |
34 | - var_export( $input->raw_value(), true), |
|
35 | - $input->html_name() . '[]' |
|
34 | + var_export($input->raw_value(), true), |
|
35 | + $input->html_name().'[]' |
|
36 | 36 | ), |
37 | 37 | '4.8.1' |
38 | 38 | ); |
39 | 39 | } |
40 | - $input_raw_value = (array)$input->raw_value(); |
|
41 | - foreach( $input->options() as $value => $display_text ){ |
|
42 | - $value = $input->get_normalization_strategy()->unnormalize_one( $value ); |
|
43 | - $html_id = $this->get_sub_input_id( $value ); |
|
44 | - $html .= EEH_HTML::nl( 0, 'checkbox' ); |
|
45 | - $html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">'; |
|
46 | - $html .= EEH_HTML::nl( 1, 'checkbox' ); |
|
40 | + $input_raw_value = (array) $input->raw_value(); |
|
41 | + foreach ($input->options() as $value => $display_text) { |
|
42 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
43 | + $html_id = $this->get_sub_input_id($value); |
|
44 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
45 | + $html .= '<label for="'.$html_id.'" id="'.$html_id.'-lbl" class="ee-checkbox-label-after'.$label_size_class.'">'; |
|
46 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
47 | 47 | $html .= '<input type="checkbox"'; |
48 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
49 | - $html .= ' id="' . $html_id . '"'; |
|
50 | - $html .= ' class="' . $input->html_class() . '"'; |
|
51 | - $html .= ' style="' . $input->html_style() . '"'; |
|
52 | - $html .= ' value="' . esc_attr( $value ) . '"'; |
|
53 | - $html .= ! empty( $input_raw_value ) && in_array( $value, $input_raw_value ) ? ' checked="checked"' : ''; |
|
54 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
48 | + $html .= ' name="'.$input->html_name().'[]"'; |
|
49 | + $html .= ' id="'.$html_id.'"'; |
|
50 | + $html .= ' class="'.$input->html_class().'"'; |
|
51 | + $html .= ' style="'.$input->html_style().'"'; |
|
52 | + $html .= ' value="'.esc_attr($value).'"'; |
|
53 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value) ? ' checked="checked"' : ''; |
|
54 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
55 | 55 | $html .= '> '; |
56 | 56 | $html .= $display_text; |
57 | - $html .= EEH_HTML::nl( -1, 'checkbox' ) . '</label>'; |
|
57 | + $html .= EEH_HTML::nl( -1, 'checkbox' ).'</label>'; |
|
58 | 58 | } |
59 | 59 | return $html; |
60 | 60 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Specialized form for payment methods, allowing for easy setting and retrieving of meta fields. |
5 | 5 | * Uses EEM_Payment_Method as the model |
6 | 6 | */ |
7 | -class EE_Payment_Method_Form extends EE_Model_Form_Section{ |
|
7 | +class EE_Payment_Method_Form extends EE_Model_Form_Section { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * All the subsection inputs that correspond ot extra meta rows |
@@ -39,37 +39,37 @@ discard block |
||
39 | 39 | * @see EE_Model_Form_Section::__construct() for more |
40 | 40 | * } |
41 | 41 | */ |
42 | - public function __construct($options_array = array()){ |
|
42 | + public function __construct($options_array = array()) { |
|
43 | 43 | $this->_model = EEM_Payment_Method::instance(); |
44 | 44 | $this->_options_array = $options_array; |
45 | - if(isset($options_array['payment_method_type'])){ |
|
45 | + if (isset($options_array['payment_method_type'])) { |
|
46 | 46 | $this->_payment_method_type = $options_array['payment_method_type']; |
47 | 47 | } |
48 | 48 | $options_array = $this->_options_array; |
49 | - if(isset($options_array['extra_meta_inputs'])){ |
|
50 | - $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs,$options_array['extra_meta_inputs']); |
|
49 | + if (isset($options_array['extra_meta_inputs'])) { |
|
50 | + $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']); |
|
51 | 51 | } |
52 | - if($this->_extra_meta_inputs){ |
|
53 | - $this->_subsections = array_merge($this->_subsections,$this->_extra_meta_inputs); |
|
52 | + if ($this->_extra_meta_inputs) { |
|
53 | + $this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs); |
|
54 | 54 | } |
55 | 55 | $this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input( |
56 | - array( 'html_label_text'=> __( 'Button URL', 'event_espresso' )) |
|
56 | + array('html_label_text'=> __('Button URL', 'event_espresso')) |
|
57 | 57 | ); |
58 | 58 | $this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input( |
59 | 59 | EEM_Payment_Method::instance()->scopes(), |
60 | - array( 'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() . EEH_Template::get_help_tab_link( 'payment_methods_overview' )) |
|
60 | + array('html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename().EEH_Template::get_help_tab_link('payment_methods_overview')) |
|
61 | 61 | ); |
62 | 62 | //setup the currency options |
63 | 63 | $this->_subsections['Currency'] = new EE_Select_Multi_Model_Input( |
64 | - EEM_Currency::instance()->get_all_currencies_usable_by( $this->_payment_method_type ), |
|
64 | + EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type), |
|
65 | 65 | array( |
66 | - 'html_label_text'=> __( 'Currencies Supported', 'event_espresso' ), |
|
66 | + 'html_label_text'=> __('Currencies Supported', 'event_espresso'), |
|
67 | 67 | 'required'=>TRUE |
68 | 68 | ) |
69 | 69 | ); |
70 | - $this->_subsections['PMD_order'] = new EE_Text_Input( array( |
|
71 | - 'html_label_text' => __( 'Order', 'event_espresso' ), |
|
72 | - 'html_help_text' => __( 'Lowest numbers will be shown first', 'event_espresso' ), |
|
70 | + $this->_subsections['PMD_order'] = new EE_Text_Input(array( |
|
71 | + 'html_label_text' => __('Order', 'event_espresso'), |
|
72 | + 'html_help_text' => __('Lowest numbers will be shown first', 'event_espresso'), |
|
73 | 73 | 'normalization_strategy' => new EE_Int_Normalization(), |
74 | 74 | 'validation_strategies' => array( |
75 | 75 | new EE_Int_Validation_Strategy() |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | )); |
79 | 79 | $this->_layout_strategy = new EE_Admin_Two_Column_Layout(); |
80 | 80 | parent::__construct($options_array); |
81 | - $debug_mode = isset( $this->_subsections[ 'PMD_debug_mode' ] ) ? $this->_subsections[ 'PMD_debug_mode' ] : null; |
|
82 | - if( $debug_mode instanceof EE_Form_Input_Base ) { |
|
83 | - $debug_mode->set_html_help_text( __( 'This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', 'event_espresso' ) ); |
|
81 | + $debug_mode = isset($this->_subsections['PMD_debug_mode']) ? $this->_subsections['PMD_debug_mode'] : null; |
|
82 | + if ($debug_mode instanceof EE_Form_Input_Base) { |
|
83 | + $debug_mode->set_html_help_text(__('This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', 'event_espresso')); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | * @param string $name |
93 | 93 | * @throws EE_Error |
94 | 94 | */ |
95 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
96 | - if( ! $this->_payment_method_type instanceof EE_PMT_Base ){ |
|
97 | - throw new EE_Error( sprintf( __( 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso' ))); |
|
95 | + public function _construct_finalize($parent_form_section, $name) { |
|
96 | + if ( ! $this->_payment_method_type instanceof EE_PMT_Base) { |
|
97 | + throw new EE_Error(sprintf(__('Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso'))); |
|
98 | 98 | } |
99 | 99 | //set the name of this form based on the payment method type |
100 | - if( ! $this->_name && ! $name ){ |
|
101 | - $name = str_replace(" ","_",ucwords(str_replace("_"," ",($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
100 | + if ( ! $this->_name && ! $name) { |
|
101 | + $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
102 | 102 | } |
103 | - parent::_construct_finalize( $parent_form_section, $name ); |
|
103 | + parent::_construct_finalize($parent_form_section, $name); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @param $payment_method_type |
110 | 110 | * @throws EE_Error |
111 | 111 | */ |
112 | - public function set_payment_method_type( $payment_method_type ){ |
|
113 | - if( ! $payment_method_type instanceof EE_PMT_Base){ |
|
112 | + public function set_payment_method_type($payment_method_type) { |
|
113 | + if ( ! $payment_method_type instanceof EE_PMT_Base) { |
|
114 | 114 | throw new EE_Error(sprintf(__("Payment Method forms MUST set a payment method type by using _set_payment_method_type", "event_espresso"))); |
115 | 115 | } |
116 | 116 | $this->_payment_method_type = $payment_method_type; |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | * extends the model form section's save method to also save the extra meta field values |
123 | 123 | * @return int ID of the payment method inserted, or true on update |
124 | 124 | */ |
125 | - public function save(){ |
|
125 | + public function save() { |
|
126 | 126 | $parent_save_val = parent::save(); |
127 | - if( $this->_model_object && $this->_model_object->ID()){ |
|
128 | - foreach($this->_extra_meta_inputs as $input_name => $input){ |
|
127 | + if ($this->_model_object && $this->_model_object->ID()) { |
|
128 | + foreach ($this->_extra_meta_inputs as $input_name => $input) { |
|
129 | 129 | $this->_model_object->update_extra_meta($input_name, $input->normalized_value()); |
130 | 130 | } |
131 | 131 | } |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
143 | 143 | parent::populate_model_obj($model_obj); |
144 | 144 | $extra_meta = $model_obj->all_extra_meta_array(); |
145 | - foreach($this->_extra_meta_inputs as $input_name => $extra_meta_input){ |
|
146 | - if(isset($extra_meta[$input_name])){ |
|
145 | + foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) { |
|
146 | + if (isset($extra_meta[$input_name])) { |
|
147 | 147 | $extra_meta_input->set_default($extra_meta[$input_name]); |
148 | 148 | } |
149 | 149 | } |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | * gets the default name of this form section if none is specified |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - protected function _set_default_name_if_empty(){ |
|
159 | - if( ! $this->_name ){ |
|
160 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
161 | - $this->_name = $default_name; |
|
158 | + protected function _set_default_name_if_empty() { |
|
159 | + if ( ! $this->_name) { |
|
160 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
161 | + $this->_name = $default_name; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * Gets all the extra meta inputs in this form |
169 | 169 | * @return EE_Form_Input_Base[] |
170 | 170 | */ |
171 | - public function extra_meta_inputs(){ |
|
171 | + public function extra_meta_inputs() { |
|
172 | 172 | return $this->_extra_meta_inputs; |
173 | 173 | } |
174 | 174 | } |