@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -38,32 +38,32 @@ discard block |
||
| 38 | 38 | public static function set_hooks() { |
| 39 | 39 | add_filter( |
| 40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
| 41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
| 41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
| 42 | 42 | ); |
| 43 | 43 | add_action( |
| 44 | 44 | 'wp_ajax_switch_spco_billing_form', |
| 45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
| 45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
| 46 | 46 | ); |
| 47 | 47 | add_action( |
| 48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
| 49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
| 49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
| 50 | 50 | ); |
| 51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
| 51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
| 52 | 52 | add_action( |
| 53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
| 54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
| 54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
| 55 | 55 | ); |
| 56 | 56 | add_action( |
| 57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
| 58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
| 58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
| 59 | 59 | ); |
| 60 | 60 | add_action( |
| 61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
| 62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
| 62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
| 63 | 63 | ); |
| 64 | 64 | add_filter( |
| 65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
| 66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
| 66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
| 67 | 67 | 10, |
| 68 | 68 | 1 |
| 69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @throws \EE_Error |
| 78 | 78 | */ |
| 79 | 79 | public static function switch_spco_billing_form() { |
| 80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
| 80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @throws \EE_Error |
| 89 | 89 | */ |
| 90 | 90 | public static function save_payer_details() { |
| 91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
| 91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @throws \EE_Error |
| 100 | 100 | */ |
| 101 | 101 | public static function get_transaction_details() { |
| 102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
| 102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | * @param EE_Checkout $checkout |
| 128 | 128 | * @return \EE_SPCO_Reg_Step_Payment_Options |
| 129 | 129 | */ |
| 130 | - public function __construct( EE_Checkout $checkout ) { |
|
| 130 | + public function __construct(EE_Checkout $checkout) { |
|
| 131 | 131 | $this->_slug = 'payment_options'; |
| 132 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
| 133 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
| 132 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
| 133 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
| 134 | 134 | $this->checkout = $checkout; |
| 135 | 135 | $this->_reset_success_message(); |
| 136 | 136 | $this->set_instructions( |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | /** |
| 156 | 156 | * @param null $line_item_display |
| 157 | 157 | */ |
| 158 | - public function set_line_item_display( $line_item_display ) { |
|
| 158 | + public function set_line_item_display($line_item_display) { |
|
| 159 | 159 | $this->line_item_display = $line_item_display; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | /** |
| 174 | 174 | * @param boolean $handle_IPN_in_this_request |
| 175 | 175 | */ |
| 176 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
| 177 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
| 176 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
| 177 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | public function enqueue_styles_and_scripts() { |
| 210 | 210 | $transaction = $this->checkout->transaction; |
| 211 | 211 | //if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
| 212 | - if( ! $transaction instanceof EE_Transaction |
|
| 213 | - || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) { |
|
| 212 | + if ( ! $transaction instanceof EE_Transaction |
|
| 213 | + || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
| 214 | 214 | return; |
| 215 | 215 | } |
| 216 | - foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) { |
|
| 216 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) { |
|
| 217 | 217 | $type_obj = $payment_method->type_obj(); |
| 218 | - if( $type_obj instanceof EE_PMT_Base ) { |
|
| 219 | - $billing_form = $type_obj->generate_new_billing_form( $transaction ); |
|
| 220 | - if( $billing_form instanceof EE_Form_Section_Proper ) { |
|
| 218 | + if ($type_obj instanceof EE_PMT_Base) { |
|
| 219 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
| 220 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 221 | 221 | $billing_form->enqueue_js(); |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -242,20 +242,20 @@ discard block |
||
| 242 | 242 | // $ 0.00 transactions (no payment required) |
| 243 | 243 | ! $this->checkout->payment_required() |
| 244 | 244 | // but do NOT remove if current action being called belongs to this reg step |
| 245 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
| 245 | + && ! is_callable(array($this, $this->checkout->action)) |
|
| 246 | 246 | && ! $this->completed() |
| 247 | 247 | ) { |
| 248 | 248 | // and if so, then we no longer need the Payment Options step |
| 249 | - if ( $this->is_current_step() ) { |
|
| 249 | + if ($this->is_current_step()) { |
|
| 250 | 250 | $this->checkout->generate_reg_form = false; |
| 251 | 251 | } |
| 252 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
| 252 | + $this->checkout->remove_reg_step($this->_slug); |
|
| 253 | 253 | // DEBUG LOG |
| 254 | 254 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
| 255 | 255 | return false; |
| 256 | 256 | } |
| 257 | 257 | // load EEM_Payment_Method |
| 258 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
| 258 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 259 | 259 | // get all active payment methods |
| 260 | 260 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
| 261 | 261 | $this->checkout->transaction, |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | $sold_out_events = array(); |
| 282 | 282 | $reg_count = 0; |
| 283 | 283 | // loop thru registrations to gather info |
| 284 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
| 285 | - foreach ( $registrations as $registration ) { |
|
| 284 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 285 | + foreach ($registrations as $registration) { |
|
| 286 | 286 | /** @var $registration EE_Registration */ |
| 287 | 287 | $reg_count++; |
| 288 | 288 | // if returning registrant is Approved then do NOT do this |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | && $registration->status_ID() === EEM_Registration::status_id_approved |
| 293 | 293 | ) |
| 294 | 294 | ) { |
| 295 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true ) ) { |
|
| 295 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
| 296 | 296 | // add event to list of events that are sold out |
| 297 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 297 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
| 298 | 298 | do_action( |
| 299 | 299 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
| 300 | 300 | $registration->event(), |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | ); |
| 303 | 303 | } |
| 304 | 304 | // event requires admin approval |
| 305 | - if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) { |
|
| 305 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
| 306 | 306 | // add event to list of events with pre-approval reg status |
| 307 | - $registrations_requiring_pre_approval[ $registration->ID() ] = $registration; |
|
| 307 | + $registrations_requiring_pre_approval[$registration->ID()] = $registration; |
|
| 308 | 308 | do_action( |
| 309 | 309 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
| 310 | 310 | $registration->event(), |
@@ -313,8 +313,8 @@ discard block |
||
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | // are they allowed to pay now and is there monies owing? |
| 316 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
| 317 | - $registrations_requiring_payment[ $registration->ID() ] = $registration; |
|
| 316 | + if ($registration->owes_monies_and_can_pay()) { |
|
| 317 | + $registrations_requiring_payment[$registration->ID()] = $registration; |
|
| 318 | 318 | do_action( |
| 319 | 319 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
| 320 | 320 | $registration->event(), |
@@ -325,23 +325,23 @@ discard block |
||
| 325 | 325 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
| 326 | 326 | && $registration->ticket()->is_free() |
| 327 | 327 | ) { |
| 328 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
| 328 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | $subsections = array(); |
| 332 | 332 | // now decide which template to load |
| 333 | - if ( ! empty( $sold_out_events ) ) { |
|
| 334 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
| 333 | + if ( ! empty($sold_out_events)) { |
|
| 334 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
| 335 | 335 | } |
| 336 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
| 336 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
| 337 | 337 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
| 338 | 338 | $registrations_requiring_pre_approval |
| 339 | 339 | ); |
| 340 | 340 | } |
| 341 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
| 342 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
| 341 | + if ( ! empty($registrations_for_free_events)) { |
|
| 342 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
| 343 | 343 | } |
| 344 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
| 344 | + if ( ! empty($registrations_requiring_payment)) { |
|
| 345 | 345 | // autoload Line_Item_Display classes |
| 346 | 346 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
| 347 | 347 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -353,17 +353,17 @@ discard block |
||
| 353 | 353 | ); |
| 354 | 354 | /** @var EE_Line_Item $filtered_line_item_tree */ |
| 355 | 355 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
| 356 | - if ( $this->checkout->amount_owing > 0 ) { |
|
| 356 | + if ($this->checkout->amount_owing > 0) { |
|
| 357 | 357 | EEH_Autoloader::register_line_item_display_autoloaders(); |
| 358 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
| 358 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
| 359 | 359 | $subsections['payment_options'] = $this->_display_payment_options( |
| 360 | 360 | $this->line_item_display->display_line_item( |
| 361 | 361 | $filtered_line_item_tree, |
| 362 | - array( 'registrations' => $registrations ) |
|
| 362 | + array('registrations' => $registrations) |
|
| 363 | 363 | ) |
| 364 | 364 | ); |
| 365 | 365 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
| 366 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
| 366 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
| 367 | 367 | } |
| 368 | 368 | } else { |
| 369 | 369 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
| 394 | 394 | * @return \EE_Line_Item_Filter_Collection |
| 395 | 395 | */ |
| 396 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
| 396 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
| 397 | 397 | $line_item_filter_collection->add( |
| 398 | 398 | new EE_Billable_Line_Item_Filter( |
| 399 | 399 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | ) |
| 402 | 402 | ) |
| 403 | 403 | ); |
| 404 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 404 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
| 405 | 405 | return $line_item_filter_collection; |
| 406 | 406 | } |
| 407 | 407 | |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | * @return void |
| 416 | 416 | */ |
| 417 | 417 | protected function _hide_reg_step_submit_button_if_revisit() { |
| 418 | - if ( $this->checkout->revisit ) { |
|
| 419 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
| 418 | + if ($this->checkout->revisit) { |
|
| 419 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | |
@@ -429,13 +429,13 @@ discard block |
||
| 429 | 429 | * @return \EE_Form_Section_Proper |
| 430 | 430 | * @throws \EE_Error |
| 431 | 431 | */ |
| 432 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
| 432 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
| 433 | 433 | // set some defaults |
| 434 | 434 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
| 435 | 435 | $sold_out_events = ''; |
| 436 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
| 436 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
| 437 | 437 | $sold_out_events .= EEH_HTML::li( |
| 438 | - EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
| 438 | + EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
| 439 | 439 | ); |
| 440 | 440 | } |
| 441 | 441 | return new EE_Form_Section_Proper( |
@@ -480,17 +480,17 @@ discard block |
||
| 480 | 480 | * @return \EE_Form_Section_Proper |
| 481 | 481 | * @throws \EE_Error |
| 482 | 482 | */ |
| 483 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
| 483 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
| 484 | 484 | $events_requiring_pre_approval = ''; |
| 485 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
| 486 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
| 487 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
| 485 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
| 486 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
| 487 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
| 488 | 488 | EEH_HTML::span( |
| 489 | 489 | '', |
| 490 | 490 | '', |
| 491 | 491 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
| 492 | 492 | ) |
| 493 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
| 493 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
| 494 | 494 | ); |
| 495 | 495 | } |
| 496 | 496 | } |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | 'template_args' => apply_filters( |
| 510 | 510 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
| 511 | 511 | array( |
| 512 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
| 512 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
| 513 | 513 | 'events_requiring_pre_approval_msg' => apply_filters( |
| 514 | 514 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
| 515 | 515 | __( |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | * @return \EE_Form_Section_Proper |
| 535 | 535 | * @throws \EE_Error |
| 536 | 536 | */ |
| 537 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
| 537 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
| 538 | 538 | // set some defaults |
| 539 | 539 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
| 540 | 540 | // generate no_payment_required form |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | 'ticket_count' => array(), |
| 559 | 559 | 'registrations_for_free_events' => $registrations_for_free_events, |
| 560 | 560 | 'no_payment_required_msg' => EEH_HTML::p( |
| 561 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
| 561 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
| 562 | 562 | ) |
| 563 | 563 | ) |
| 564 | 564 | ), |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | * @return \EE_Form_Section_Proper |
| 578 | 578 | * @throws \EE_Error |
| 579 | 579 | */ |
| 580 | - private function _display_payment_options( $transaction_details = '' ) { |
|
| 580 | + private function _display_payment_options($transaction_details = '') { |
|
| 581 | 581 | // has method_of_payment been set by no-js user? |
| 582 | 582 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
| 583 | 583 | // build payment options form |
@@ -589,18 +589,18 @@ discard block |
||
| 589 | 589 | 'before_payment_options' => apply_filters( |
| 590 | 590 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
| 591 | 591 | new EE_Form_Section_Proper( |
| 592 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
| 592 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
| 593 | 593 | ) |
| 594 | 594 | ), |
| 595 | 595 | 'payment_options' => $this->_setup_payment_options(), |
| 596 | 596 | 'after_payment_options' => apply_filters( |
| 597 | 597 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
| 598 | 598 | new EE_Form_Section_Proper( |
| 599 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
| 599 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
| 600 | 600 | ) |
| 601 | 601 | ), |
| 602 | 602 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
| 603 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( false ) |
|
| 603 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(false) |
|
| 604 | 604 | ), |
| 605 | 605 | 'layout_strategy' => new EE_Template_Layout( |
| 606 | 606 | array( |
@@ -629,10 +629,10 @@ discard block |
||
| 629 | 629 | * @return \EE_Form_Section_Proper |
| 630 | 630 | * @throws \EE_Error |
| 631 | 631 | */ |
| 632 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
| 632 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
| 633 | 633 | return new EE_Form_Section_Proper( |
| 634 | 634 | array( |
| 635 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
| 635 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
| 636 | 636 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
| 637 | 637 | 'subsections' => array( |
| 638 | 638 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -664,16 +664,16 @@ discard block |
||
| 664 | 664 | * @access protected |
| 665 | 665 | * @param array $registrations |
| 666 | 666 | */ |
| 667 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
| 667 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
| 668 | 668 | $payments = array(); |
| 669 | - foreach ( $registrations as $registration ) { |
|
| 670 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
| 669 | + foreach ($registrations as $registration) { |
|
| 670 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
| 671 | 671 | $payments += $registration->registration_payments(); |
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | - if ( ! empty( $payments ) ) { |
|
| 675 | - foreach ( $payments as $payment ) { |
|
| 676 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
| 674 | + if ( ! empty($payments)) { |
|
| 675 | + foreach ($payments as $payment) { |
|
| 676 | + if ($payment instanceof EE_Registration_Payment) { |
|
| 677 | 677 | $this->checkout->amount_owing -= $payment->amount(); |
| 678 | 678 | } |
| 679 | 679 | } |
@@ -689,11 +689,11 @@ discard block |
||
| 689 | 689 | * @param bool $force_reset |
| 690 | 690 | * @return void |
| 691 | 691 | */ |
| 692 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
| 692 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
| 693 | 693 | $reset_payment_method = $force_reset |
| 694 | 694 | ? true |
| 695 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
| 696 | - if ( $reset_payment_method ) { |
|
| 695 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
| 696 | + if ($reset_payment_method) { |
|
| 697 | 697 | $this->checkout->selected_method_of_payment = null; |
| 698 | 698 | $this->checkout->payment_method = null; |
| 699 | 699 | $this->checkout->billing_form = null; |
@@ -712,12 +712,12 @@ discard block |
||
| 712 | 712 | * @param string $selected_method_of_payment |
| 713 | 713 | * @return EE_Billing_Info_Form |
| 714 | 714 | */ |
| 715 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
| 716 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
| 715 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
| 716 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
| 717 | 717 | ? $selected_method_of_payment |
| 718 | 718 | : $this->checkout->selected_method_of_payment; |
| 719 | 719 | EE_Registry::instance()->SSN->set_session_data( |
| 720 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
| 720 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
| 721 | 721 | ); |
| 722 | 722 | } |
| 723 | 723 | |
@@ -733,19 +733,19 @@ discard block |
||
| 733 | 733 | // load payment method classes |
| 734 | 734 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
| 735 | 735 | // switch up header depending on number of available payment methods |
| 736 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
| 736 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
| 737 | 737 | ? apply_filters( |
| 738 | 738 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
| 739 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
| 739 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
| 740 | 740 | ) |
| 741 | 741 | : apply_filters( |
| 742 | 742 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
| 743 | - __( 'Method of Payment', 'event_espresso' ) |
|
| 743 | + __('Method of Payment', 'event_espresso') |
|
| 744 | 744 | ); |
| 745 | 745 | $available_payment_methods = array( |
| 746 | 746 | // display the "Payment Method" header |
| 747 | 747 | 'payment_method_header' => new EE_Form_Section_HTML( |
| 748 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
| 748 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
| 749 | 749 | ) |
| 750 | 750 | ); |
| 751 | 751 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -754,32 +754,32 @@ discard block |
||
| 754 | 754 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
| 755 | 755 | $payment_methods_billing_info = array( |
| 756 | 756 | new EE_Form_Section_HTML( |
| 757 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
| 757 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
| 758 | 758 | ) |
| 759 | 759 | ); |
| 760 | 760 | // loop through payment methods |
| 761 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
| 762 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
| 761 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
| 762 | + if ($payment_method instanceof EE_Payment_Method) { |
|
| 763 | 763 | $payment_method_button = EEH_HTML::img( |
| 764 | 764 | $payment_method->button_url(), |
| 765 | 765 | $payment_method->name(), |
| 766 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
| 766 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
| 767 | 767 | 'spco-payment-method-btn-img' |
| 768 | 768 | ); |
| 769 | 769 | // check if any payment methods are set as default |
| 770 | 770 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
| 771 | 771 | if ( |
| 772 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
| 773 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
| 772 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
| 773 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
| 774 | 774 | ) { |
| 775 | 775 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
| 776 | 776 | $this->_save_selected_method_of_payment(); |
| 777 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
| 777 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
| 778 | 778 | } else { |
| 779 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
| 779 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
| 780 | 780 | } |
| 781 | - $payment_methods_billing_info[ $payment_method->slug() |
|
| 782 | - . '-info' ] = $this->_payment_method_billing_info( |
|
| 781 | + $payment_methods_billing_info[$payment_method->slug() |
|
| 782 | + . '-info'] = $this->_payment_method_billing_info( |
|
| 783 | 783 | $payment_method |
| 784 | 784 | ); |
| 785 | 785 | } |
@@ -809,12 +809,12 @@ discard block |
||
| 809 | 809 | * @return EE_Payment_Method[] |
| 810 | 810 | */ |
| 811 | 811 | protected function _get_available_payment_methods() { |
| 812 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
| 812 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
| 813 | 813 | return $this->checkout->available_payment_methods; |
| 814 | 814 | } |
| 815 | 815 | $available_payment_methods = array(); |
| 816 | 816 | // load EEM_Payment_Method |
| 817 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
| 817 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 818 | 818 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
| 819 | 819 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
| 820 | 820 | // get all active payment methods |
@@ -822,9 +822,9 @@ discard block |
||
| 822 | 822 | $this->checkout->transaction, |
| 823 | 823 | EEM_Payment_Method::scope_cart |
| 824 | 824 | ); |
| 825 | - foreach ( $payment_methods as $payment_method ) { |
|
| 826 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
| 827 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
| 825 | + foreach ($payment_methods as $payment_method) { |
|
| 826 | + if ($payment_method instanceof EE_Payment_Method) { |
|
| 827 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
| 828 | 828 | } |
| 829 | 829 | } |
| 830 | 830 | return $available_payment_methods; |
@@ -839,14 +839,14 @@ discard block |
||
| 839 | 839 | * @param array $available_payment_method_options |
| 840 | 840 | * @return \EE_Form_Section_Proper |
| 841 | 841 | */ |
| 842 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
| 842 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
| 843 | 843 | // generate inputs |
| 844 | 844 | return new EE_Form_Section_Proper( |
| 845 | 845 | array( |
| 846 | 846 | 'html_id' => 'ee-available-payment-method-inputs', |
| 847 | 847 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
| 848 | 848 | 'subsections' => array( |
| 849 | - '' => new EE_Radio_Button_Input ( |
|
| 849 | + '' => new EE_Radio_Button_Input( |
|
| 850 | 850 | $available_payment_method_options, |
| 851 | 851 | array( |
| 852 | 852 | 'html_name' => 'selected_method_of_payment', |
@@ -871,28 +871,28 @@ discard block |
||
| 871 | 871 | * @return \EE_Form_Section_Proper |
| 872 | 872 | * @throws \EE_Error |
| 873 | 873 | */ |
| 874 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
| 874 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
| 875 | 875 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
| 876 | 876 | ? true |
| 877 | 877 | : false; |
| 878 | 878 | // generate the billing form for payment method |
| 879 | 879 | $billing_form = $currently_selected |
| 880 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
| 880 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
| 881 | 881 | : new EE_Form_Section_HTML(); |
| 882 | 882 | $this->checkout->billing_form = $currently_selected |
| 883 | 883 | ? $billing_form |
| 884 | 884 | : $this->checkout->billing_form; |
| 885 | 885 | // it's all in the details |
| 886 | 886 | $info_html = EEH_HTML::h3( |
| 887 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
| 887 | + __('Important information regarding your payment', 'event_espresso'), |
|
| 888 | 888 | '', |
| 889 | 889 | 'spco-payment-method-hdr' |
| 890 | 890 | ); |
| 891 | 891 | // add some info regarding the step, either from what's saved in the admin, |
| 892 | 892 | // or a default string depending on whether the PM has a billing form or not |
| 893 | - if ( $payment_method->description() ) { |
|
| 893 | + if ($payment_method->description()) { |
|
| 894 | 894 | $payment_method_info = $payment_method->description(); |
| 895 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
| 895 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
| 896 | 896 | $payment_method_info = sprintf( |
| 897 | 897 | __( |
| 898 | 898 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | ); |
| 903 | 903 | } else { |
| 904 | 904 | $payment_method_info = sprintf( |
| 905 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
| 905 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
| 906 | 906 | $this->submit_button_text() |
| 907 | 907 | ); |
| 908 | 908 | } |
@@ -916,13 +916,13 @@ discard block |
||
| 916 | 916 | ); |
| 917 | 917 | return new EE_Form_Section_Proper( |
| 918 | 918 | array( |
| 919 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
| 919 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
| 920 | 920 | 'html_class' => 'spco-payment-method-info-dv', |
| 921 | 921 | // only display the selected or default PM |
| 922 | 922 | 'html_style' => $currently_selected ? '' : 'display:none;', |
| 923 | 923 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
| 924 | 924 | 'subsections' => array( |
| 925 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
| 925 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
| 926 | 926 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
| 927 | 927 | ) |
| 928 | 928 | ) |
@@ -940,15 +940,15 @@ discard block |
||
| 940 | 940 | */ |
| 941 | 941 | public function get_billing_form_html_for_payment_method() { |
| 942 | 942 | // how have they chosen to pay? |
| 943 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
| 943 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 944 | 944 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
| 945 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
| 945 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 946 | 946 | return false; |
| 947 | 947 | } |
| 948 | - if ( apply_filters( |
|
| 948 | + if (apply_filters( |
|
| 949 | 949 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
| 950 | 950 | false |
| 951 | - ) ) { |
|
| 951 | + )) { |
|
| 952 | 952 | EE_Error::add_success( |
| 953 | 953 | apply_filters( |
| 954 | 954 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -963,7 +963,7 @@ discard block |
||
| 963 | 963 | ); |
| 964 | 964 | } |
| 965 | 965 | // now generate billing form for selected method of payment |
| 966 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
| 966 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
| 967 | 967 | // fill form with attendee info if applicable |
| 968 | 968 | if ( |
| 969 | 969 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -985,10 +985,10 @@ discard block |
||
| 985 | 985 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
| 986 | 986 | ? $payment_method_billing_form->get_html() |
| 987 | 987 | : ''; |
| 988 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
| 988 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
| 989 | 989 | // localize validation rules for main form |
| 990 | 990 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
| 991 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
| 991 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 992 | 992 | return true; |
| 993 | 993 | } |
| 994 | 994 | |
@@ -1002,18 +1002,18 @@ discard block |
||
| 1002 | 1002 | * @return \EE_Billing_Info_Form |
| 1003 | 1003 | * @throws \EE_Error |
| 1004 | 1004 | */ |
| 1005 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
| 1005 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
| 1006 | 1006 | $billing_form = $payment_method->type_obj()->billing_form( |
| 1007 | 1007 | $this->checkout->transaction, |
| 1008 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
| 1008 | + array('amount_owing' => $this->checkout->amount_owing) |
|
| 1009 | 1009 | ); |
| 1010 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
| 1010 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
| 1011 | 1011 | if ( |
| 1012 | 1012 | apply_filters( |
| 1013 | 1013 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
| 1014 | 1014 | false |
| 1015 | 1015 | ) |
| 1016 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
| 1016 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
| 1017 | 1017 | ) { |
| 1018 | 1018 | EE_Error::add_success( |
| 1019 | 1019 | apply_filters( |
@@ -1055,15 +1055,15 @@ discard block |
||
| 1055 | 1055 | $request_param = 'selected_method_of_payment' |
| 1056 | 1056 | ) { |
| 1057 | 1057 | // is selected_method_of_payment set in the request ? |
| 1058 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
| 1059 | - if ( $selected_method_of_payment ) { |
|
| 1058 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
| 1059 | + if ($selected_method_of_payment) { |
|
| 1060 | 1060 | // sanitize it |
| 1061 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
| 1062 | - ? array_shift( $selected_method_of_payment ) |
|
| 1061 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
| 1062 | + ? array_shift($selected_method_of_payment) |
|
| 1063 | 1063 | : $selected_method_of_payment; |
| 1064 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
| 1064 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
| 1065 | 1065 | // store it in the session so that it's available for all subsequent requests including AJAX |
| 1066 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
| 1066 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
| 1067 | 1067 | } else { |
| 1068 | 1068 | // or is is set in the session ? |
| 1069 | 1069 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | ); |
| 1072 | 1072 | } |
| 1073 | 1073 | // do ya really really gotta have it? |
| 1074 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
| 1074 | + if (empty($selected_method_of_payment) && $required) { |
|
| 1075 | 1075 | EE_Error::add_error( |
| 1076 | 1076 | sprintf( |
| 1077 | 1077 | __( |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | ), |
| 1081 | 1081 | '<br/>', |
| 1082 | 1082 | '<br/>', |
| 1083 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1083 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1084 | 1084 | ), |
| 1085 | 1085 | __FILE__, |
| 1086 | 1086 | __FUNCTION__, |
@@ -1107,13 +1107,13 @@ discard block |
||
| 1107 | 1107 | * @throws \EE_Error |
| 1108 | 1108 | */ |
| 1109 | 1109 | public function switch_payment_method() { |
| 1110 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
| 1110 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
| 1111 | 1111 | return false; |
| 1112 | 1112 | } |
| 1113 | - if ( apply_filters( |
|
| 1113 | + if (apply_filters( |
|
| 1114 | 1114 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
| 1115 | 1115 | false |
| 1116 | - ) ) { |
|
| 1116 | + )) { |
|
| 1117 | 1117 | EE_Error::add_success( |
| 1118 | 1118 | apply_filters( |
| 1119 | 1119 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1128,13 +1128,13 @@ discard block |
||
| 1128 | 1128 | ); |
| 1129 | 1129 | } |
| 1130 | 1130 | // generate billing form for selected method of payment if it hasn't been done already |
| 1131 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
| 1131 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1132 | 1132 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
| 1133 | 1133 | $this->checkout->payment_method |
| 1134 | 1134 | ); |
| 1135 | 1135 | } |
| 1136 | 1136 | // fill form with attendee info if applicable |
| 1137 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 1137 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 1138 | 1138 | && $this->checkout->transaction_has_primary_registrant() |
| 1139 | 1139 | ) { |
| 1140 | 1140 | $this->checkout->billing_form->populate_from_attendee( |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | ); |
| 1143 | 1143 | } |
| 1144 | 1144 | // and debug content |
| 1145 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
| 1145 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
| 1146 | 1146 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
| 1147 | 1147 | ) { |
| 1148 | 1148 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1150,15 +1150,15 @@ discard block |
||
| 1150 | 1150 | ); |
| 1151 | 1151 | } |
| 1152 | 1152 | // get html and validation rules for form |
| 1153 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
| 1153 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
| 1154 | 1154 | $this->checkout->json_response->set_return_data( |
| 1155 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
| 1155 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
| 1156 | 1156 | ); |
| 1157 | 1157 | // localize validation rules for main form |
| 1158 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
| 1159 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
| 1158 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
| 1159 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 1160 | 1160 | } else { |
| 1161 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
| 1161 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
| 1162 | 1162 | } |
| 1163 | 1163 | //prevents advancement to next step |
| 1164 | 1164 | $this->checkout->continue_reg = false; |
@@ -1175,12 +1175,12 @@ discard block |
||
| 1175 | 1175 | */ |
| 1176 | 1176 | protected function _verify_payment_method_is_set() { |
| 1177 | 1177 | // generate billing form for selected method of payment if it hasn't been done already |
| 1178 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
| 1178 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
| 1179 | 1179 | // how have they chosen to pay? |
| 1180 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
| 1180 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | // verify payment method |
| 1183 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
| 1183 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1184 | 1184 | // get payment method for selected method of payment |
| 1185 | 1185 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
| 1186 | 1186 | } |
@@ -1199,25 +1199,25 @@ discard block |
||
| 1199 | 1199 | * @throws \EE_Error |
| 1200 | 1200 | */ |
| 1201 | 1201 | public function save_payer_details_via_ajax() { |
| 1202 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
| 1202 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
| 1203 | 1203 | return; |
| 1204 | 1204 | } |
| 1205 | 1205 | // generate billing form for selected method of payment if it hasn't been done already |
| 1206 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
| 1206 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1207 | 1207 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
| 1208 | 1208 | $this->checkout->payment_method |
| 1209 | 1209 | ); |
| 1210 | 1210 | } |
| 1211 | 1211 | // generate primary attendee from payer info if applicable |
| 1212 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
| 1212 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
| 1213 | 1213 | $attendee = $this->_create_attendee_from_request_data(); |
| 1214 | - if ( $attendee instanceof EE_Attendee ) { |
|
| 1215 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
| 1216 | - if ( $registration->is_primary_registrant() ) { |
|
| 1214 | + if ($attendee instanceof EE_Attendee) { |
|
| 1215 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
| 1216 | + if ($registration->is_primary_registrant()) { |
|
| 1217 | 1217 | $this->checkout->primary_attendee_obj = $attendee; |
| 1218 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
| 1219 | - $registration->set_attendee_id( $attendee->ID() ); |
|
| 1220 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
| 1218 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
| 1219 | + $registration->set_attendee_id($attendee->ID()); |
|
| 1220 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | } |
| 1223 | 1223 | } |
@@ -1234,50 +1234,50 @@ discard block |
||
| 1234 | 1234 | */ |
| 1235 | 1235 | protected function _create_attendee_from_request_data() { |
| 1236 | 1236 | // get State ID |
| 1237 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
| 1238 | - if ( ! empty( $STA_ID ) ) { |
|
| 1237 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
| 1238 | + if ( ! empty($STA_ID)) { |
|
| 1239 | 1239 | // can we get state object from name ? |
| 1240 | - EE_Registry::instance()->load_model( 'State' ); |
|
| 1241 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
| 1242 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
| 1240 | + EE_Registry::instance()->load_model('State'); |
|
| 1241 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
| 1242 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
| 1243 | 1243 | } |
| 1244 | 1244 | // get Country ISO |
| 1245 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
| 1246 | - if ( ! empty( $CNT_ISO ) ) { |
|
| 1245 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
| 1246 | + if ( ! empty($CNT_ISO)) { |
|
| 1247 | 1247 | // can we get country object from name ? |
| 1248 | - EE_Registry::instance()->load_model( 'Country' ); |
|
| 1248 | + EE_Registry::instance()->load_model('Country'); |
|
| 1249 | 1249 | $country = EEM_Country::instance()->get_col( |
| 1250 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
| 1250 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
| 1251 | 1251 | 'CNT_ISO' |
| 1252 | 1252 | ); |
| 1253 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
| 1253 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
| 1254 | 1254 | } |
| 1255 | 1255 | // grab attendee data |
| 1256 | 1256 | $attendee_data = array( |
| 1257 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
| 1258 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
| 1259 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
| 1260 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
| 1261 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
| 1262 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
| 1257 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
| 1258 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
| 1259 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
| 1260 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
| 1261 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
| 1262 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
| 1263 | 1263 | 'STA_ID' => $STA_ID, |
| 1264 | 1264 | 'CNT_ISO' => $CNT_ISO, |
| 1265 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
| 1266 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
| 1265 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
| 1266 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
| 1267 | 1267 | ); |
| 1268 | 1268 | // validate the email address since it is the most important piece of info |
| 1269 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
| 1269 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
| 1270 | 1270 | EE_Error::add_error( |
| 1271 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
| 1271 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
| 1272 | 1272 | __FILE__, |
| 1273 | 1273 | __FUNCTION__, |
| 1274 | 1274 | __LINE__ |
| 1275 | 1275 | ); |
| 1276 | 1276 | } |
| 1277 | 1277 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
| 1278 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
| 1279 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
| 1280 | - && ! empty( $attendee_data['ATT_email'] ) |
|
| 1278 | + if ( ! empty($attendee_data['ATT_fname']) |
|
| 1279 | + && ! empty($attendee_data['ATT_lname']) |
|
| 1280 | + && ! empty($attendee_data['ATT_email']) |
|
| 1281 | 1281 | ) { |
| 1282 | 1282 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
| 1283 | 1283 | array( |
@@ -1286,19 +1286,19 @@ discard block |
||
| 1286 | 1286 | 'ATT_email' => $attendee_data['ATT_email'] |
| 1287 | 1287 | ) |
| 1288 | 1288 | ); |
| 1289 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
| 1289 | + if ($existing_attendee instanceof EE_Attendee) { |
|
| 1290 | 1290 | return $existing_attendee; |
| 1291 | 1291 | } |
| 1292 | 1292 | } |
| 1293 | 1293 | // no existing attendee? kk let's create a new one |
| 1294 | 1294 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
| 1295 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
| 1295 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
| 1296 | 1296 | ? $attendee_data['ATT_fname'] |
| 1297 | 1297 | : $attendee_data['ATT_email']; |
| 1298 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
| 1298 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
| 1299 | 1299 | ? $attendee_data['ATT_lname'] |
| 1300 | 1300 | : $attendee_data['ATT_email']; |
| 1301 | - return EE_Attendee::new_instance( $attendee_data ); |
|
| 1301 | + return EE_Attendee::new_instance($attendee_data); |
|
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | |
@@ -1316,26 +1316,26 @@ discard block |
||
| 1316 | 1316 | // how have they chosen to pay? |
| 1317 | 1317 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
| 1318 | 1318 | ? 'no_payment_required' |
| 1319 | - : $this->_get_selected_method_of_payment( true ); |
|
| 1319 | + : $this->_get_selected_method_of_payment(true); |
|
| 1320 | 1320 | // choose your own adventure based on method_of_payment |
| 1321 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
| 1321 | + switch ($this->checkout->selected_method_of_payment) { |
|
| 1322 | 1322 | |
| 1323 | 1323 | case 'events_sold_out' : |
| 1324 | 1324 | $this->checkout->redirect = true; |
| 1325 | 1325 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
| 1326 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
| 1326 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
| 1327 | 1327 | // mark this reg step as completed |
| 1328 | 1328 | $this->set_completed(); |
| 1329 | 1329 | return false; |
| 1330 | 1330 | break; |
| 1331 | 1331 | |
| 1332 | 1332 | case 'payments_closed' : |
| 1333 | - if ( apply_filters( |
|
| 1333 | + if (apply_filters( |
|
| 1334 | 1334 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
| 1335 | 1335 | false |
| 1336 | - ) ) { |
|
| 1336 | + )) { |
|
| 1337 | 1337 | EE_Error::add_success( |
| 1338 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
| 1338 | + __('no payment required at this time.', 'event_espresso'), |
|
| 1339 | 1339 | __FILE__, |
| 1340 | 1340 | __FUNCTION__, |
| 1341 | 1341 | __LINE__ |
@@ -1347,12 +1347,12 @@ discard block |
||
| 1347 | 1347 | break; |
| 1348 | 1348 | |
| 1349 | 1349 | case 'no_payment_required' : |
| 1350 | - if ( apply_filters( |
|
| 1350 | + if (apply_filters( |
|
| 1351 | 1351 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
| 1352 | 1352 | false |
| 1353 | - ) ) { |
|
| 1353 | + )) { |
|
| 1354 | 1354 | EE_Error::add_success( |
| 1355 | - __( 'no payment required.', 'event_espresso' ), |
|
| 1355 | + __('no payment required.', 'event_espresso'), |
|
| 1356 | 1356 | __FILE__, |
| 1357 | 1357 | __FUNCTION__, |
| 1358 | 1358 | __LINE__ |
@@ -1365,9 +1365,9 @@ discard block |
||
| 1365 | 1365 | |
| 1366 | 1366 | default: |
| 1367 | 1367 | $payment_successful = $this->_process_payment(); |
| 1368 | - if ( $payment_successful ) { |
|
| 1368 | + if ($payment_successful) { |
|
| 1369 | 1369 | $this->checkout->continue_reg = true; |
| 1370 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
| 1370 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
| 1371 | 1371 | } else { |
| 1372 | 1372 | $this->checkout->continue_reg = false; |
| 1373 | 1373 | } |
@@ -1386,8 +1386,8 @@ discard block |
||
| 1386 | 1386 | * @return void |
| 1387 | 1387 | * @throws \EE_Error |
| 1388 | 1388 | */ |
| 1389 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
| 1390 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
| 1389 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
| 1390 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
| 1391 | 1391 | case EE_PMT_Base::offsite : |
| 1392 | 1392 | break; |
| 1393 | 1393 | case EE_PMT_Base::onsite : |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | public function update_reg_step() { |
| 1411 | 1411 | $success = true; |
| 1412 | 1412 | // if payment required |
| 1413 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
| 1413 | + if ($this->checkout->transaction->total() > 0) { |
|
| 1414 | 1414 | do_action( |
| 1415 | 1415 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
| 1416 | 1416 | $this->checkout->transaction |
@@ -1418,13 +1418,13 @@ discard block |
||
| 1418 | 1418 | // attempt payment via payment method |
| 1419 | 1419 | $success = $this->process_reg_step(); |
| 1420 | 1420 | } |
| 1421 | - if ( $success && ! $this->checkout->redirect ) { |
|
| 1421 | + if ($success && ! $this->checkout->redirect) { |
|
| 1422 | 1422 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
| 1423 | 1423 | $this->checkout->transaction->ID() |
| 1424 | 1424 | ); |
| 1425 | 1425 | // set return URL |
| 1426 | 1426 | $this->checkout->redirect_url = add_query_arg( |
| 1427 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
| 1427 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
| 1428 | 1428 | $this->checkout->thank_you_page_url |
| 1429 | 1429 | ); |
| 1430 | 1430 | } |
@@ -1444,28 +1444,28 @@ discard block |
||
| 1444 | 1444 | // clear any previous errors related to not selecting a payment method |
| 1445 | 1445 | // EE_Error::overwrite_errors(); |
| 1446 | 1446 | // ya gotta make a choice man |
| 1447 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
| 1447 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
| 1448 | 1448 | $this->checkout->json_response->set_plz_select_method_of_payment( |
| 1449 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
| 1449 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
| 1450 | 1450 | ); |
| 1451 | 1451 | return false; |
| 1452 | 1452 | } |
| 1453 | 1453 | // get EE_Payment_Method object |
| 1454 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
| 1454 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 1455 | 1455 | return false; |
| 1456 | 1456 | } |
| 1457 | 1457 | // setup billing form |
| 1458 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
| 1458 | + if ($this->checkout->payment_method->is_on_site()) { |
|
| 1459 | 1459 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
| 1460 | 1460 | $this->checkout->payment_method |
| 1461 | 1461 | ); |
| 1462 | 1462 | // bad billing form ? |
| 1463 | - if ( ! $this->_billing_form_is_valid() ) { |
|
| 1463 | + if ( ! $this->_billing_form_is_valid()) { |
|
| 1464 | 1464 | return false; |
| 1465 | 1465 | } |
| 1466 | 1466 | } |
| 1467 | 1467 | // ensure primary registrant has been fully processed |
| 1468 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
| 1468 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
| 1469 | 1469 | return false; |
| 1470 | 1470 | } |
| 1471 | 1471 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1473,18 +1473,18 @@ discard block |
||
| 1473 | 1473 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
| 1474 | 1474 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
| 1475 | 1475 | // attempt payment |
| 1476 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
| 1476 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
| 1477 | 1477 | // process results |
| 1478 | - $payment = $this->_validate_payment( $payment ); |
|
| 1479 | - $payment = $this->_post_payment_processing( $payment ); |
|
| 1478 | + $payment = $this->_validate_payment($payment); |
|
| 1479 | + $payment = $this->_post_payment_processing($payment); |
|
| 1480 | 1480 | // verify payment |
| 1481 | - if ( $payment instanceof EE_Payment ) { |
|
| 1481 | + if ($payment instanceof EE_Payment) { |
|
| 1482 | 1482 | // store that for later |
| 1483 | 1483 | $this->checkout->payment = $payment; |
| 1484 | 1484 | /** @type EE_Transaction_Processor $transaction_processor */ |
| 1485 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
| 1485 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 1486 | 1486 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
| 1487 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
| 1487 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
| 1488 | 1488 | $payment_status = $payment->status(); |
| 1489 | 1489 | if ( |
| 1490 | 1490 | $payment_status === EEM_Payment::status_id_approved |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | } else { |
| 1495 | 1495 | return false; |
| 1496 | 1496 | } |
| 1497 | - } else if ( $payment === true ) { |
|
| 1497 | + } else if ($payment === true) { |
|
| 1498 | 1498 | // please note that offline payment methods will NOT make a payment, |
| 1499 | 1499 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
| 1500 | 1500 | $this->checkout->payment = $payment; |
@@ -1519,7 +1519,7 @@ discard block |
||
| 1519 | 1519 | ); |
| 1520 | 1520 | $html = $payment_method_billing_info->get_html_and_js(); |
| 1521 | 1521 | $html .= $this->checkout->redirect_form; |
| 1522 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
| 1522 | + EE_Registry::instance()->REQ->add_output($html); |
|
| 1523 | 1523 | return true; |
| 1524 | 1524 | } |
| 1525 | 1525 | |
@@ -1533,28 +1533,28 @@ discard block |
||
| 1533 | 1533 | * @throws \EE_Error |
| 1534 | 1534 | */ |
| 1535 | 1535 | private function _billing_form_is_valid() { |
| 1536 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
| 1536 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1537 | 1537 | return true; |
| 1538 | 1538 | } |
| 1539 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
| 1540 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
| 1539 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
| 1540 | + if ($this->checkout->billing_form->was_submitted()) { |
|
| 1541 | 1541 | $this->checkout->billing_form->receive_form_submission(); |
| 1542 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
| 1542 | + if ($this->checkout->billing_form->is_valid()) { |
|
| 1543 | 1543 | return true; |
| 1544 | 1544 | } |
| 1545 | 1545 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
| 1546 | 1546 | $error_strings = array(); |
| 1547 | - foreach ( $validation_errors as $validation_error ) { |
|
| 1548 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
| 1547 | + foreach ($validation_errors as $validation_error) { |
|
| 1548 | + if ($validation_error instanceof EE_Validation_Error) { |
|
| 1549 | 1549 | $form_section = $validation_error->get_form_section(); |
| 1550 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
| 1550 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
| 1551 | 1551 | $label = $form_section->html_label_text(); |
| 1552 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
| 1552 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
| 1553 | 1553 | $label = $form_section->name(); |
| 1554 | 1554 | } else { |
| 1555 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
| 1555 | + $label = __('Validation Error', 'event_espresso'); |
|
| 1556 | 1556 | } |
| 1557 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
| 1557 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
| 1558 | 1558 | } |
| 1559 | 1559 | } |
| 1560 | 1560 | EE_Error::add_error( |
@@ -1564,7 +1564,7 @@ discard block |
||
| 1564 | 1564 | 'event_espresso' |
| 1565 | 1565 | ), |
| 1566 | 1566 | '<br/>', |
| 1567 | - implode( '<br/>', $error_strings ) |
|
| 1567 | + implode('<br/>', $error_strings) |
|
| 1568 | 1568 | ), |
| 1569 | 1569 | __FILE__, |
| 1570 | 1570 | __FUNCTION__, |
@@ -1583,7 +1583,7 @@ discard block |
||
| 1583 | 1583 | } |
| 1584 | 1584 | } else { |
| 1585 | 1585 | EE_Error::add_error( |
| 1586 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
| 1586 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
| 1587 | 1587 | __FILE__, |
| 1588 | 1588 | __FUNCTION__, |
| 1589 | 1589 | __LINE__ |
@@ -1618,13 +1618,13 @@ discard block |
||
| 1618 | 1618 | // grab the primary_registration object |
| 1619 | 1619 | $primary_registration = $this->checkout->transaction->primary_registration(); |
| 1620 | 1620 | /** @type EE_Transaction_Processor $transaction_processor */ |
| 1621 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
| 1621 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 1622 | 1622 | // at this point we'll consider a TXN to not have been failed |
| 1623 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
| 1623 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
| 1624 | 1624 | // save the TXN ( which clears cached copy of primary_registration) |
| 1625 | 1625 | $this->checkout->transaction->save(); |
| 1626 | 1626 | // grab TXN ID and save it to the primary_registration |
| 1627 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
| 1627 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
| 1628 | 1628 | // save what we have so far |
| 1629 | 1629 | $primary_registration->save(); |
| 1630 | 1630 | return true; |
@@ -1642,7 +1642,7 @@ discard block |
||
| 1642 | 1642 | private function _capture_primary_registration_data_from_billing_form() { |
| 1643 | 1643 | // convert billing form data into an attendee |
| 1644 | 1644 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
| 1645 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
| 1645 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
| 1646 | 1646 | EE_Error::add_error( |
| 1647 | 1647 | sprintf( |
| 1648 | 1648 | __( |
@@ -1650,7 +1650,7 @@ discard block |
||
| 1650 | 1650 | 'event_espresso' |
| 1651 | 1651 | ), |
| 1652 | 1652 | '<br/>', |
| 1653 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1653 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1654 | 1654 | ), |
| 1655 | 1655 | __FILE__, |
| 1656 | 1656 | __FUNCTION__, |
@@ -1659,7 +1659,7 @@ discard block |
||
| 1659 | 1659 | return false; |
| 1660 | 1660 | } |
| 1661 | 1661 | $primary_registration = $this->checkout->transaction->primary_registration(); |
| 1662 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
| 1662 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
| 1663 | 1663 | EE_Error::add_error( |
| 1664 | 1664 | sprintf( |
| 1665 | 1665 | __( |
@@ -1667,7 +1667,7 @@ discard block |
||
| 1667 | 1667 | 'event_espresso' |
| 1668 | 1668 | ), |
| 1669 | 1669 | '<br/>', |
| 1670 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1670 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1671 | 1671 | ), |
| 1672 | 1672 | __FILE__, |
| 1673 | 1673 | __FUNCTION__, |
@@ -1675,7 +1675,7 @@ discard block |
||
| 1675 | 1675 | ); |
| 1676 | 1676 | return false; |
| 1677 | 1677 | } |
| 1678 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
| 1678 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
| 1679 | 1679 | instanceof |
| 1680 | 1680 | EE_Attendee |
| 1681 | 1681 | ) { |
@@ -1686,7 +1686,7 @@ discard block |
||
| 1686 | 1686 | 'event_espresso' |
| 1687 | 1687 | ), |
| 1688 | 1688 | '<br/>', |
| 1689 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1689 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1690 | 1690 | ), |
| 1691 | 1691 | __FILE__, |
| 1692 | 1692 | __FUNCTION__, |
@@ -1695,9 +1695,9 @@ discard block |
||
| 1695 | 1695 | return false; |
| 1696 | 1696 | } |
| 1697 | 1697 | /** @type EE_Registration_Processor $registration_processor */ |
| 1698 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
| 1698 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 1699 | 1699 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
| 1700 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
| 1700 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
| 1701 | 1701 | return true; |
| 1702 | 1702 | } |
| 1703 | 1703 | |
@@ -1713,17 +1713,17 @@ discard block |
||
| 1713 | 1713 | */ |
| 1714 | 1714 | private function _get_payment_method_for_selected_method_of_payment() { |
| 1715 | 1715 | // get EE_Payment_Method object |
| 1716 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
| 1717 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
| 1716 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
| 1717 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
| 1718 | 1718 | } else { |
| 1719 | 1719 | // load EEM_Payment_Method |
| 1720 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
| 1720 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 1721 | 1721 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
| 1722 | 1722 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
| 1723 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
| 1723 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
| 1724 | 1724 | } |
| 1725 | 1725 | // verify $payment_method |
| 1726 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
| 1726 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
| 1727 | 1727 | // not a payment |
| 1728 | 1728 | EE_Error::add_error( |
| 1729 | 1729 | sprintf( |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | 'event_espresso' |
| 1733 | 1733 | ), |
| 1734 | 1734 | '<br/>', |
| 1735 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1735 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1736 | 1736 | ), |
| 1737 | 1737 | __FILE__, |
| 1738 | 1738 | __FUNCTION__, |
@@ -1741,7 +1741,7 @@ discard block |
||
| 1741 | 1741 | return null; |
| 1742 | 1742 | } |
| 1743 | 1743 | // and verify it has a valid Payment_Method Type object |
| 1744 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
| 1744 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 1745 | 1745 | // not a payment |
| 1746 | 1746 | EE_Error::add_error( |
| 1747 | 1747 | sprintf( |
@@ -1750,7 +1750,7 @@ discard block |
||
| 1750 | 1750 | 'event_espresso' |
| 1751 | 1751 | ), |
| 1752 | 1752 | '<br/>', |
| 1753 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1753 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1754 | 1754 | ), |
| 1755 | 1755 | __FILE__, |
| 1756 | 1756 | __FUNCTION__, |
@@ -1771,29 +1771,29 @@ discard block |
||
| 1771 | 1771 | * @return mixed EE_Payment | boolean |
| 1772 | 1772 | * @throws \EE_Error |
| 1773 | 1773 | */ |
| 1774 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
| 1774 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
| 1775 | 1775 | $payment = null; |
| 1776 | 1776 | $this->checkout->transaction->save(); |
| 1777 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
| 1778 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
| 1777 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 1778 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
| 1779 | 1779 | return false; |
| 1780 | 1780 | } |
| 1781 | 1781 | try { |
| 1782 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
| 1782 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
| 1783 | 1783 | // generate payment object |
| 1784 | 1784 | $payment = $payment_processor->process_payment( |
| 1785 | 1785 | $payment_method, |
| 1786 | 1786 | $this->checkout->transaction, |
| 1787 | 1787 | $this->checkout->amount_owing, |
| 1788 | 1788 | $this->checkout->billing_form, |
| 1789 | - $this->_get_return_url( $payment_method ), |
|
| 1789 | + $this->_get_return_url($payment_method), |
|
| 1790 | 1790 | 'CART', |
| 1791 | 1791 | $this->checkout->admin_request, |
| 1792 | 1792 | true, |
| 1793 | 1793 | $this->reg_step_url() |
| 1794 | 1794 | ); |
| 1795 | - } catch ( Exception $e ) { |
|
| 1796 | - $this->_handle_payment_processor_exception( $e ); |
|
| 1795 | + } catch (Exception $e) { |
|
| 1796 | + $this->_handle_payment_processor_exception($e); |
|
| 1797 | 1797 | } |
| 1798 | 1798 | return $payment; |
| 1799 | 1799 | } |
@@ -1808,7 +1808,7 @@ discard block |
||
| 1808 | 1808 | * @return void |
| 1809 | 1809 | * @throws \EE_Error |
| 1810 | 1810 | */ |
| 1811 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
| 1811 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
| 1812 | 1812 | EE_Error::add_error( |
| 1813 | 1813 | sprintf( |
| 1814 | 1814 | __( |
@@ -1816,7 +1816,7 @@ discard block |
||
| 1816 | 1816 | 'event_espresso' |
| 1817 | 1817 | ), |
| 1818 | 1818 | '<br/>', |
| 1819 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
| 1819 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
| 1820 | 1820 | $e->getMessage(), |
| 1821 | 1821 | $e->getFile(), |
| 1822 | 1822 | $e->getLine() |
@@ -1837,9 +1837,9 @@ discard block |
||
| 1837 | 1837 | * @return string |
| 1838 | 1838 | * @throws \EE_Error |
| 1839 | 1839 | */ |
| 1840 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
| 1840 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
| 1841 | 1841 | $return_url = ''; |
| 1842 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
| 1842 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
| 1843 | 1843 | case EE_PMT_Base::offsite : |
| 1844 | 1844 | $return_url = add_query_arg( |
| 1845 | 1845 | array( |
@@ -1868,12 +1868,12 @@ discard block |
||
| 1868 | 1868 | * @return EE_Payment | FALSE |
| 1869 | 1869 | * @throws \EE_Error |
| 1870 | 1870 | */ |
| 1871 | - private function _validate_payment( $payment = null ) { |
|
| 1872 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
| 1871 | + private function _validate_payment($payment = null) { |
|
| 1872 | + if ($this->checkout->payment_method->is_off_line()) { |
|
| 1873 | 1873 | return true; |
| 1874 | 1874 | } |
| 1875 | 1875 | // verify payment object |
| 1876 | - if ( ! $payment instanceof EE_Payment ) { |
|
| 1876 | + if ( ! $payment instanceof EE_Payment) { |
|
| 1877 | 1877 | // not a payment |
| 1878 | 1878 | EE_Error::add_error( |
| 1879 | 1879 | sprintf( |
@@ -1882,7 +1882,7 @@ discard block |
||
| 1882 | 1882 | 'event_espresso' |
| 1883 | 1883 | ), |
| 1884 | 1884 | '<br/>', |
| 1885 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1885 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1886 | 1886 | ), |
| 1887 | 1887 | __FILE__, |
| 1888 | 1888 | __FUNCTION__, |
@@ -1903,27 +1903,27 @@ discard block |
||
| 1903 | 1903 | * @return bool |
| 1904 | 1904 | * @throws \EE_Error |
| 1905 | 1905 | */ |
| 1906 | - private function _post_payment_processing( $payment = null ) { |
|
| 1906 | + private function _post_payment_processing($payment = null) { |
|
| 1907 | 1907 | // Off-Line payment? |
| 1908 | - if ( $payment === true ) { |
|
| 1908 | + if ($payment === true) { |
|
| 1909 | 1909 | //$this->_setup_redirect_for_next_step(); |
| 1910 | 1910 | return true; |
| 1911 | 1911 | // On-Site payment? |
| 1912 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
| 1913 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
| 1912 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
| 1913 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
| 1914 | 1914 | //$this->_setup_redirect_for_next_step(); |
| 1915 | 1915 | $this->checkout->continue_reg = false; |
| 1916 | 1916 | } |
| 1917 | 1917 | // Off-Site payment? |
| 1918 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
| 1918 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
| 1919 | 1919 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
| 1920 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
| 1921 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
| 1920 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
| 1921 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
| 1922 | 1922 | $this->checkout->redirect = true; |
| 1923 | 1923 | $this->checkout->redirect_form = $payment->redirect_form(); |
| 1924 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
| 1924 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
| 1925 | 1925 | // set JSON response |
| 1926 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
| 1926 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
| 1927 | 1927 | // set cron job for finalizing the TXN |
| 1928 | 1928 | // in case the user does not return from the off-site gateway |
| 1929 | 1929 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -1931,7 +1931,7 @@ discard block |
||
| 1931 | 1931 | $this->checkout->transaction->ID() |
| 1932 | 1932 | ); |
| 1933 | 1933 | // and lastly, let's bump the payment status to pending |
| 1934 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
| 1934 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
| 1935 | 1935 | $payment->save(); |
| 1936 | 1936 | } else { |
| 1937 | 1937 | // not a payment |
@@ -1943,7 +1943,7 @@ discard block |
||
| 1943 | 1943 | 'event_espresso' |
| 1944 | 1944 | ), |
| 1945 | 1945 | '<br/>', |
| 1946 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1946 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1947 | 1947 | ), |
| 1948 | 1948 | __FILE__, |
| 1949 | 1949 | __FUNCTION__, |
@@ -1981,21 +1981,21 @@ discard block |
||
| 1981 | 1981 | * @return bool |
| 1982 | 1982 | * @throws \EE_Error |
| 1983 | 1983 | */ |
| 1984 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
| 1984 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
| 1985 | 1985 | // off-line payment? carry on |
| 1986 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
| 1986 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
| 1987 | 1987 | return true; |
| 1988 | 1988 | } |
| 1989 | 1989 | // verify payment validity |
| 1990 | - if ( $payment instanceof EE_Payment ) { |
|
| 1991 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
| 1990 | + if ($payment instanceof EE_Payment) { |
|
| 1991 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
| 1992 | 1992 | $msg = $payment->gateway_response(); |
| 1993 | 1993 | // check results |
| 1994 | - switch ( $payment->status() ) { |
|
| 1994 | + switch ($payment->status()) { |
|
| 1995 | 1995 | // good payment |
| 1996 | 1996 | case EEM_Payment::status_id_approved : |
| 1997 | 1997 | EE_Error::add_success( |
| 1998 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
| 1998 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
| 1999 | 1999 | __FILE__, |
| 2000 | 2000 | __FUNCTION__, |
| 2001 | 2001 | __LINE__ |
@@ -2004,45 +2004,45 @@ discard block |
||
| 2004 | 2004 | break; |
| 2005 | 2005 | // slow payment |
| 2006 | 2006 | case EEM_Payment::status_id_pending : |
| 2007 | - if ( empty( $msg ) ) { |
|
| 2007 | + if (empty($msg)) { |
|
| 2008 | 2008 | $msg = __( |
| 2009 | 2009 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
| 2010 | 2010 | 'event_espresso' |
| 2011 | 2011 | ); |
| 2012 | 2012 | } |
| 2013 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2013 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2014 | 2014 | return true; |
| 2015 | 2015 | break; |
| 2016 | 2016 | // don't wanna payment |
| 2017 | 2017 | case EEM_Payment::status_id_cancelled : |
| 2018 | - if ( empty( $msg ) ) { |
|
| 2018 | + if (empty($msg)) { |
|
| 2019 | 2019 | $msg = _n( |
| 2020 | 2020 | 'Payment cancelled. Please try again.', |
| 2021 | 2021 | 'Payment cancelled. Please try again or select another method of payment.', |
| 2022 | - count( $this->checkout->available_payment_methods ), |
|
| 2022 | + count($this->checkout->available_payment_methods), |
|
| 2023 | 2023 | 'event_espresso' |
| 2024 | 2024 | ); |
| 2025 | 2025 | } |
| 2026 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2026 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2027 | 2027 | return false; |
| 2028 | 2028 | break; |
| 2029 | 2029 | // not enough payment |
| 2030 | 2030 | case EEM_Payment::status_id_declined : |
| 2031 | - if ( empty( $msg ) ) { |
|
| 2031 | + if (empty($msg)) { |
|
| 2032 | 2032 | $msg = _n( |
| 2033 | 2033 | 'We\'re sorry but your payment was declined. Please try again.', |
| 2034 | 2034 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
| 2035 | - count( $this->checkout->available_payment_methods ), |
|
| 2035 | + count($this->checkout->available_payment_methods), |
|
| 2036 | 2036 | 'event_espresso' |
| 2037 | 2037 | ); |
| 2038 | 2038 | } |
| 2039 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2039 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2040 | 2040 | return false; |
| 2041 | 2041 | break; |
| 2042 | 2042 | // bad payment |
| 2043 | 2043 | case EEM_Payment::status_id_failed : |
| 2044 | - if ( ! empty( $msg ) ) { |
|
| 2045 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2044 | + if ( ! empty($msg)) { |
|
| 2045 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2046 | 2046 | return false; |
| 2047 | 2047 | } |
| 2048 | 2048 | // default to error below |
@@ -2051,7 +2051,7 @@ discard block |
||
| 2051 | 2051 | } |
| 2052 | 2052 | // off-site payment gateway responses are too unreliable, so let's just assume that |
| 2053 | 2053 | // the payment processing is just running slower than the registrant's request |
| 2054 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
| 2054 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
| 2055 | 2055 | return true; |
| 2056 | 2056 | } |
| 2057 | 2057 | EE_Error::add_error( |
@@ -2061,7 +2061,7 @@ discard block |
||
| 2061 | 2061 | 'event_espresso' |
| 2062 | 2062 | ), |
| 2063 | 2063 | '<br/>', |
| 2064 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 2064 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2065 | 2065 | ), |
| 2066 | 2066 | __FILE__, |
| 2067 | 2067 | __FUNCTION__, |
@@ -2094,13 +2094,13 @@ discard block |
||
| 2094 | 2094 | public function process_gateway_response() { |
| 2095 | 2095 | $payment = null; |
| 2096 | 2096 | // how have they chosen to pay? |
| 2097 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
| 2097 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 2098 | 2098 | // get EE_Payment_Method object |
| 2099 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
| 2099 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 2100 | 2100 | $this->checkout->continue_reg = false; |
| 2101 | 2101 | return false; |
| 2102 | 2102 | } |
| 2103 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
| 2103 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
| 2104 | 2104 | return false; |
| 2105 | 2105 | } |
| 2106 | 2106 | $this->_validate_offsite_return(); |
@@ -2114,23 +2114,23 @@ discard block |
||
| 2114 | 2114 | // true |
| 2115 | 2115 | //); |
| 2116 | 2116 | // verify TXN |
| 2117 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
| 2117 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 2118 | 2118 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
| 2119 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
| 2119 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
| 2120 | 2120 | $this->checkout->continue_reg = false; |
| 2121 | 2121 | return false; |
| 2122 | 2122 | } |
| 2123 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
| 2124 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
| 2125 | - $payment = $this->_validate_payment( $payment ); |
|
| 2123 | + $payment = $this->_process_off_site_payment($gateway); |
|
| 2124 | + $payment = $this->_process_cancelled_payments($payment); |
|
| 2125 | + $payment = $this->_validate_payment($payment); |
|
| 2126 | 2126 | // if payment was not declined by the payment gateway or cancelled by the registrant |
| 2127 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
| 2127 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
| 2128 | 2128 | //$this->_setup_redirect_for_next_step(); |
| 2129 | 2129 | // store that for later |
| 2130 | 2130 | $this->checkout->payment = $payment; |
| 2131 | 2131 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
| 2132 | 2132 | // because we will complete this step during the IPN processing then |
| 2133 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
| 2133 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
| 2134 | 2134 | $this->set_completed(); |
| 2135 | 2135 | } |
| 2136 | 2136 | return true; |
@@ -2154,21 +2154,21 @@ discard block |
||
| 2154 | 2154 | * @throws \EE_Error |
| 2155 | 2155 | */ |
| 2156 | 2156 | private function _validate_offsite_return() { |
| 2157 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
| 2158 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
| 2157 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
| 2158 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
| 2159 | 2159 | // Houston... we might have a problem |
| 2160 | 2160 | $invalid_TXN = false; |
| 2161 | 2161 | // first gather some info |
| 2162 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
| 2162 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 2163 | 2163 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
| 2164 | 2164 | ? $valid_TXN->primary_registration() |
| 2165 | 2165 | : null; |
| 2166 | 2166 | // let's start by retrieving the cart for this TXN |
| 2167 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
| 2168 | - if ( $cart instanceof EE_Cart ) { |
|
| 2167 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
| 2168 | + if ($cart instanceof EE_Cart) { |
|
| 2169 | 2169 | // verify that the current cart has tickets |
| 2170 | 2170 | $tickets = $cart->get_tickets(); |
| 2171 | - if ( empty( $tickets ) ) { |
|
| 2171 | + if (empty($tickets)) { |
|
| 2172 | 2172 | $invalid_TXN = true; |
| 2173 | 2173 | } |
| 2174 | 2174 | } else { |
@@ -2178,39 +2178,39 @@ discard block |
||
| 2178 | 2178 | ? $primary_registrant->session_ID() |
| 2179 | 2179 | : null; |
| 2180 | 2180 | // validate current Session ID and compare against valid TXN session ID |
| 2181 | - if ( EE_Session::instance()->id() === null ) { |
|
| 2181 | + if (EE_Session::instance()->id() === null) { |
|
| 2182 | 2182 | $invalid_TXN = true; |
| 2183 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
| 2183 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
| 2184 | 2184 | // WARNING !!! |
| 2185 | 2185 | // this could be PayPal sending back duplicate requests (ya they do that) |
| 2186 | 2186 | // or it **could** mean someone is simply registering AGAIN after having just done so |
| 2187 | 2187 | // so now we need to determine if this current TXN looks valid or not |
| 2188 | 2188 | /** @type EE_Transaction_Processor $transaction_processor */ |
| 2189 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
| 2189 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 2190 | 2190 | // has this step even been started ? |
| 2191 | - if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false ) |
|
| 2191 | + if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false) |
|
| 2192 | 2192 | ) { |
| 2193 | 2193 | // really? you're half way through this reg step, but you never started it ? |
| 2194 | 2194 | $invalid_TXN = true; |
| 2195 | 2195 | } |
| 2196 | 2196 | } |
| 2197 | - if ( $invalid_TXN ) { |
|
| 2197 | + if ($invalid_TXN) { |
|
| 2198 | 2198 | // is the valid TXN completed ? |
| 2199 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
| 2199 | + if ($valid_TXN instanceof EE_Transaction) { |
|
| 2200 | 2200 | /** @type EE_Transaction_Processor $transaction_processor */ |
| 2201 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
| 2201 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 2202 | 2202 | // has this step even been started ? |
| 2203 | - $reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() ); |
|
| 2204 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
| 2203 | + $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); |
|
| 2204 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
| 2205 | 2205 | // so it **looks** like this is a double request from PayPal |
| 2206 | 2206 | // so let's try to pick up where we left off |
| 2207 | 2207 | $this->checkout->transaction = $valid_TXN; |
| 2208 | - $this->checkout->refresh_all_entities( true ); |
|
| 2208 | + $this->checkout->refresh_all_entities(true); |
|
| 2209 | 2209 | return; |
| 2210 | 2210 | } |
| 2211 | 2211 | } |
| 2212 | 2212 | // you appear to be lost? |
| 2213 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
| 2213 | + $this->_redirect_wayward_request($primary_registrant); |
|
| 2214 | 2214 | } |
| 2215 | 2215 | } |
| 2216 | 2216 | } |
@@ -2225,14 +2225,14 @@ discard block |
||
| 2225 | 2225 | * @return bool |
| 2226 | 2226 | * @throws \EE_Error |
| 2227 | 2227 | */ |
| 2228 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
| 2229 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
| 2228 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
| 2229 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
| 2230 | 2230 | // try redirecting based on the current TXN |
| 2231 | 2231 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
| 2232 | 2232 | ? $this->checkout->transaction->primary_registration() |
| 2233 | 2233 | : null; |
| 2234 | 2234 | } |
| 2235 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
| 2235 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
| 2236 | 2236 | EE_Error::add_error( |
| 2237 | 2237 | sprintf( |
| 2238 | 2238 | __( |
@@ -2240,7 +2240,7 @@ discard block |
||
| 2240 | 2240 | 'event_espresso' |
| 2241 | 2241 | ), |
| 2242 | 2242 | '<br/>', |
| 2243 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 2243 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2244 | 2244 | ), |
| 2245 | 2245 | __FILE__, |
| 2246 | 2246 | __FUNCTION__, |
@@ -2271,17 +2271,17 @@ discard block |
||
| 2271 | 2271 | * @return \EE_Payment |
| 2272 | 2272 | * @throws \EE_Error |
| 2273 | 2273 | */ |
| 2274 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
| 2274 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
| 2275 | 2275 | try { |
| 2276 | 2276 | $request_data = \EE_Registry::instance()->REQ->params(); |
| 2277 | 2277 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
| 2278 | 2278 | $this->set_handle_IPN_in_this_request( |
| 2279 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
| 2279 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
| 2280 | 2280 | ); |
| 2281 | - if ( $this->handle_IPN_in_this_request() ) { |
|
| 2281 | + if ($this->handle_IPN_in_this_request()) { |
|
| 2282 | 2282 | // get payment details and process results |
| 2283 | 2283 | /** @type EE_Payment_Processor $payment_processor */ |
| 2284 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
| 2284 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 2285 | 2285 | $payment = $payment_processor->process_ipn( |
| 2286 | 2286 | $request_data, |
| 2287 | 2287 | $this->checkout->transaction, |
@@ -2294,14 +2294,14 @@ discard block |
||
| 2294 | 2294 | $payment = $this->checkout->transaction->last_payment(); |
| 2295 | 2295 | //$payment_source = 'last_payment'; |
| 2296 | 2296 | } |
| 2297 | - } catch ( Exception $e ) { |
|
| 2297 | + } catch (Exception $e) { |
|
| 2298 | 2298 | // let's just eat the exception and try to move on using any previously set payment info |
| 2299 | 2299 | $payment = $this->checkout->transaction->last_payment(); |
| 2300 | 2300 | //$payment_source = 'last_payment after Exception'; |
| 2301 | 2301 | // but if we STILL don't have a payment object |
| 2302 | - if ( ! $payment instanceof EE_Payment ) { |
|
| 2302 | + if ( ! $payment instanceof EE_Payment) { |
|
| 2303 | 2303 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
| 2304 | - $this->_handle_payment_processor_exception( $e ); |
|
| 2304 | + $this->_handle_payment_processor_exception($e); |
|
| 2305 | 2305 | } |
| 2306 | 2306 | } |
| 2307 | 2307 | // DEBUG LOG |
@@ -2326,13 +2326,13 @@ discard block |
||
| 2326 | 2326 | * @return EE_Payment | FALSE |
| 2327 | 2327 | * @throws \EE_Error |
| 2328 | 2328 | */ |
| 2329 | - private function _process_cancelled_payments( $payment = null ) { |
|
| 2329 | + private function _process_cancelled_payments($payment = null) { |
|
| 2330 | 2330 | if ( |
| 2331 | 2331 | $payment instanceof EE_Payment |
| 2332 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
| 2332 | + && isset($_REQUEST['ee_cancel_payment']) |
|
| 2333 | 2333 | && $payment->status() === EEM_Payment::status_id_failed |
| 2334 | 2334 | ) { |
| 2335 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
| 2335 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
| 2336 | 2336 | } |
| 2337 | 2337 | return $payment; |
| 2338 | 2338 | } |
@@ -2349,14 +2349,14 @@ discard block |
||
| 2349 | 2349 | public function get_transaction_details_for_gateways() { |
| 2350 | 2350 | $txn_details = array(); |
| 2351 | 2351 | // ya gotta make a choice man |
| 2352 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
| 2352 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
| 2353 | 2353 | $txn_details = array( |
| 2354 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
| 2354 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
| 2355 | 2355 | ); |
| 2356 | 2356 | } |
| 2357 | 2357 | // get EE_Payment_Method object |
| 2358 | 2358 | if ( |
| 2359 | - empty( $txn_details ) |
|
| 2359 | + empty($txn_details) |
|
| 2360 | 2360 | && |
| 2361 | 2361 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
| 2362 | 2362 | ) { |
@@ -2368,8 +2368,8 @@ discard block |
||
| 2368 | 2368 | ) |
| 2369 | 2369 | ); |
| 2370 | 2370 | } |
| 2371 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
| 2372 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
| 2371 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
| 2372 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
| 2373 | 2373 | $txn_details = array( |
| 2374 | 2374 | 'TXN_ID' => $this->checkout->transaction->ID(), |
| 2375 | 2375 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2380,7 +2380,7 @@ discard block |
||
| 2380 | 2380 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
| 2381 | 2381 | 'payment_amount' => $this->checkout->amount_owing, |
| 2382 | 2382 | 'return_url' => $return_url, |
| 2383 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
| 2383 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
| 2384 | 2384 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
| 2385 | 2385 | array( |
| 2386 | 2386 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2389,7 +2389,7 @@ discard block |
||
| 2389 | 2389 | ) |
| 2390 | 2390 | ); |
| 2391 | 2391 | } |
| 2392 | - echo json_encode( $txn_details ); |
|
| 2392 | + echo json_encode($txn_details); |
|
| 2393 | 2393 | exit(); |
| 2394 | 2394 | } |
| 2395 | 2395 | |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | |
| 24 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 25 | - exit( 'No direct script access allowed' ); |
|
| 24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 25 | + exit('No direct script access allowed'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | class Model_Data_Translator { |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | * @param string $requested_version |
| 41 | 41 | * @return mixed |
| 42 | 42 | */ |
| 43 | - public static function prepare_field_values_from_json( $field_obj, $original_value_maybe_array, $requested_version ) { |
|
| 44 | - if( is_array( $original_value_maybe_array ) ) { |
|
| 43 | + public static function prepare_field_values_from_json($field_obj, $original_value_maybe_array, $requested_version) { |
|
| 44 | + if (is_array($original_value_maybe_array)) { |
|
| 45 | 45 | $new_value_maybe_array = array(); |
| 46 | - foreach( $original_value_maybe_array as $array_key => $array_item ) { |
|
| 47 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_from_json( $field_obj, $array_item, $requested_version ); |
|
| 46 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
| 47 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_from_json($field_obj, $array_item, $requested_version); |
|
| 48 | 48 | } |
| 49 | 49 | } else { |
| 50 | - $new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json( $field_obj, $original_value_maybe_array, $requested_version ); |
|
| 50 | + $new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json($field_obj, $original_value_maybe_array, $requested_version); |
|
| 51 | 51 | } |
| 52 | 52 | return $new_value_maybe_array; |
| 53 | 53 | } |
@@ -59,14 +59,14 @@ discard block |
||
| 59 | 59 | * @param string $request_version (eg 4.8.36) |
| 60 | 60 | * @return array |
| 61 | 61 | */ |
| 62 | - public static function prepare_field_values_for_json( $field_obj, $original_value_maybe_array, $request_version ){ |
|
| 63 | - if( is_array( $original_value_maybe_array ) ) { |
|
| 62 | + public static function prepare_field_values_for_json($field_obj, $original_value_maybe_array, $request_version) { |
|
| 63 | + if (is_array($original_value_maybe_array)) { |
|
| 64 | 64 | $new_value_maybe_array = array(); |
| 65 | - foreach( $original_value_maybe_array as $array_key => $array_item ) { |
|
| 66 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_for_json( $field_obj, $array_item, $request_version ); |
|
| 65 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
| 66 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_for_json($field_obj, $array_item, $request_version); |
|
| 67 | 67 | } |
| 68 | 68 | } else { |
| 69 | - $new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json( $field_obj, $original_value_maybe_array, $request_version ); |
|
| 69 | + $new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json($field_obj, $original_value_maybe_array, $request_version); |
|
| 70 | 70 | } |
| 71 | 71 | return $new_value_maybe_array; |
| 72 | 72 | } |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | * @param string $requested_version |
| 80 | 80 | * @return mixed |
| 81 | 81 | */ |
| 82 | - public static function prepare_field_value_from_json( $field_obj, $original_value, $requested_version ) { |
|
| 82 | + public static function prepare_field_value_from_json($field_obj, $original_value, $requested_version) { |
|
| 83 | 83 | $new_value = null; |
| 84 | - if( $field_obj instanceof \EE_Infinite_Integer_Field |
|
| 85 | - && in_array( $original_value, array( null, '' ), true ) ) { |
|
| 84 | + if ($field_obj instanceof \EE_Infinite_Integer_Field |
|
| 85 | + && in_array($original_value, array(null, ''), true)) { |
|
| 86 | 86 | $new_value = EE_INF; |
| 87 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
| 88 | - $new_value = rest_parse_date( $original_value ); |
|
| 87 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
| 88 | + $new_value = rest_parse_date($original_value); |
|
| 89 | 89 | } else { |
| 90 | 90 | $new_value = $original_value; |
| 91 | 91 | } |
@@ -98,22 +98,22 @@ discard block |
||
| 98 | 98 | * @param mixed $original_value |
| 99 | 99 | * @return mixed |
| 100 | 100 | */ |
| 101 | - public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
|
| 102 | - if( $original_value === EE_INF ) { |
|
| 101 | + public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) { |
|
| 102 | + if ($original_value === EE_INF) { |
|
| 103 | 103 | $new_value = Model_Data_Translator::ee_inf_in_rest; |
| 104 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
| 105 | - if( $original_value instanceof \DateTime ) { |
|
| 106 | - $new_value = $original_value->format( 'Y-m-d H:i:s' ); |
|
| 107 | - } elseif( is_int( $original_value ) ) { |
|
| 108 | - $new_value = date( 'Y-m-d H:i:s', $original_value ); |
|
| 104 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
| 105 | + if ($original_value instanceof \DateTime) { |
|
| 106 | + $new_value = $original_value->format('Y-m-d H:i:s'); |
|
| 107 | + } elseif (is_int($original_value)) { |
|
| 108 | + $new_value = date('Y-m-d H:i:s', $original_value); |
|
| 109 | 109 | } else { |
| 110 | 110 | $new_value = $original_value; |
| 111 | 111 | } |
| 112 | - $new_value = mysql_to_rfc3339( $new_value ); |
|
| 112 | + $new_value = mysql_to_rfc3339($new_value); |
|
| 113 | 113 | } else { |
| 114 | 114 | $new_value = $original_value; |
| 115 | 115 | } |
| 116 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
| 116 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
| 117 | 117 | $new_value, |
| 118 | 118 | $field_obj, |
| 119 | 119 | $original_value, |
@@ -129,29 +129,29 @@ discard block |
||
| 129 | 129 | * @param string $requested_version |
| 130 | 130 | * @return array |
| 131 | 131 | */ |
| 132 | - public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
| 132 | + public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
| 133 | 133 | $query_param_for_models = array(); |
| 134 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
| 134 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
| 135 | 135 | $field = Model_Data_Translator::deduce_field_from_query_param( |
| 136 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
| 136 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
| 137 | 137 | $model |
| 138 | 138 | ); |
| 139 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
| 139 | + if ($field instanceof \EE_Model_Field_Base) { |
|
| 140 | 140 | //did they specify an operator? |
| 141 | - if( is_array( $query_param_value ) ) { |
|
| 142 | - $op = $query_param_value[ 0 ]; |
|
| 143 | - $translated_value = array( $op ); |
|
| 144 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
| 145 | - $value = $query_param_value[ 1 ]; |
|
| 146 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json( $field, $value, $requested_version ); |
|
| 141 | + if (is_array($query_param_value)) { |
|
| 142 | + $op = $query_param_value[0]; |
|
| 143 | + $translated_value = array($op); |
|
| 144 | + if (isset($query_param_value[1])) { |
|
| 145 | + $value = $query_param_value[1]; |
|
| 146 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json($field, $value, $requested_version); |
|
| 147 | 147 | } |
| 148 | 148 | } else { |
| 149 | - $translated_value = Model_Data_Translator::prepare_field_value_from_json( $field, $query_param_value, $requested_version ); |
|
| 149 | + $translated_value = Model_Data_Translator::prepare_field_value_from_json($field, $query_param_value, $requested_version); |
|
| 150 | 150 | } |
| 151 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
| 151 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
| 152 | 152 | } else { |
| 153 | 153 | //so it's not for a field, assume it's a logic query param key |
| 154 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version ); |
|
| 154 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | return $query_param_for_models; |
@@ -164,27 +164,27 @@ discard block |
||
| 164 | 164 | * @param string $requested_version eg "4.8.36". If null is provided, defaults to the latest release of the EE4 REST API |
| 165 | 165 | * @return array which can be passed into the EE4 REST API when querying a model resource |
| 166 | 166 | */ |
| 167 | - public static function prepare_query_params_for_rest_api( $model_query_params, \EEM_Base $model, $requested_version = null ) { |
|
| 168 | - if( $requested_version === null ) { |
|
| 169 | - $requested_version = \EED_Core_Rest_Api::latest_rest_api_version() ; |
|
| 167 | + public static function prepare_query_params_for_rest_api($model_query_params, \EEM_Base $model, $requested_version = null) { |
|
| 168 | + if ($requested_version === null) { |
|
| 169 | + $requested_version = \EED_Core_Rest_Api::latest_rest_api_version(); |
|
| 170 | 170 | } |
| 171 | 171 | $rest_query_params = $model_query_params; |
| 172 | - if ( isset( $model_query_params[0] ) ) { |
|
| 173 | - $rest_query_params[ 'where' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
| 174 | - $model_query_params[ 0 ], |
|
| 172 | + if (isset($model_query_params[0])) { |
|
| 173 | + $rest_query_params['where'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
| 174 | + $model_query_params[0], |
|
| 175 | 175 | $model, |
| 176 | 176 | $requested_version |
| 177 | 177 | ); |
| 178 | - unset( $rest_query_params[0] ); |
|
| 178 | + unset($rest_query_params[0]); |
|
| 179 | 179 | } |
| 180 | - if ( isset( $model_query_params[ 'having' ] ) ) { |
|
| 181 | - $rest_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
| 182 | - $model_query_params[ 'having' ], |
|
| 180 | + if (isset($model_query_params['having'])) { |
|
| 181 | + $rest_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
| 182 | + $model_query_params['having'], |
|
| 183 | 183 | $model, |
| 184 | 184 | $requested_version |
| 185 | 185 | ); |
| 186 | 186 | } |
| 187 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version ); |
|
| 187 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -194,39 +194,39 @@ discard block |
||
| 194 | 194 | * @param string $requested_version eg "4.8.36" |
| 195 | 195 | * @return array ready for use in the rest api query params |
| 196 | 196 | */ |
| 197 | - public static function prepare_conditions_query_params_for_rest_api( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
| 197 | + public static function prepare_conditions_query_params_for_rest_api($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
| 198 | 198 | $query_param_for_models = array(); |
| 199 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
| 199 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
| 200 | 200 | $field = Model_Data_Translator::deduce_field_from_query_param( |
| 201 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
| 201 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
| 202 | 202 | $model |
| 203 | 203 | ); |
| 204 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
| 204 | + if ($field instanceof \EE_Model_Field_Base) { |
|
| 205 | 205 | //did they specify an operator? |
| 206 | - if( is_array( $query_param_value ) ) { |
|
| 207 | - $op = $query_param_value[ 0 ]; |
|
| 208 | - $translated_value = array( $op ); |
|
| 209 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
| 210 | - $value = $query_param_value[ 1 ]; |
|
| 211 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json( $field, $value, $requested_version ); |
|
| 206 | + if (is_array($query_param_value)) { |
|
| 207 | + $op = $query_param_value[0]; |
|
| 208 | + $translated_value = array($op); |
|
| 209 | + if (isset($query_param_value[1])) { |
|
| 210 | + $value = $query_param_value[1]; |
|
| 211 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json($field, $value, $requested_version); |
|
| 212 | 212 | } |
| 213 | 213 | } else { |
| 214 | - $translated_value = Model_Data_Translator::prepare_field_value_for_json( $field, $query_param_value, $requested_version ); |
|
| 214 | + $translated_value = Model_Data_Translator::prepare_field_value_for_json($field, $query_param_value, $requested_version); |
|
| 215 | 215 | } |
| 216 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
| 216 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
| 217 | 217 | } else { |
| 218 | 218 | //so it's not for a field, assume it's a logic query param key |
| 219 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( $query_param_value, $model, $requested_version ); |
|
| 219 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api($query_param_value, $model, $requested_version); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | return $query_param_for_models; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
|
| 225 | + public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
| 226 | 226 | $pos_of_star = strpos($condition_query_param_key, '*'); |
| 227 | - if($pos_of_star === FALSE){ |
|
| 227 | + if ($pos_of_star === FALSE) { |
|
| 228 | 228 | return $condition_query_param_key; |
| 229 | - }else{ |
|
| 229 | + } else { |
|
| 230 | 230 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
| 231 | 231 | return $condition_query_param_sans_star; |
| 232 | 232 | } |
@@ -238,26 +238,26 @@ discard block |
||
| 238 | 238 | * @throws EE_Error |
| 239 | 239 | * @return EE_Model_Field_Base |
| 240 | 240 | */ |
| 241 | - public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){ |
|
| 241 | + public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) { |
|
| 242 | 242 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
| 243 | 243 | //which will help us find the database table and column |
| 244 | 244 | |
| 245 | - $query_param_parts = explode(".",$query_param_name); |
|
| 246 | - if(empty($query_param_parts)){ |
|
| 247 | - throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
| 245 | + $query_param_parts = explode(".", $query_param_name); |
|
| 246 | + if (empty($query_param_parts)) { |
|
| 247 | + throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
| 248 | 248 | } |
| 249 | 249 | $number_of_parts = count($query_param_parts); |
| 250 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
| 251 | - if($number_of_parts == 1){ |
|
| 250 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
| 251 | + if ($number_of_parts == 1) { |
|
| 252 | 252 | $field_name = $last_query_param_part; |
| 253 | - }else{// $number_of_parts >= 2 |
|
| 253 | + } else {// $number_of_parts >= 2 |
|
| 254 | 254 | //the last part is the column name, and there are only 2parts. therefore... |
| 255 | 255 | $field_name = $last_query_param_part; |
| 256 | - $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
|
| 256 | + $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]); |
|
| 257 | 257 | } |
| 258 | - try{ |
|
| 258 | + try { |
|
| 259 | 259 | return $model->field_settings_for($field_name); |
| 260 | - }catch(\EE_Error $e){ |
|
| 260 | + } catch (\EE_Error $e) { |
|
| 261 | 261 | return null; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @author Mike Nelson |
| 10 | 10 | */ |
| 11 | 11 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
| 12 | -class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base{ |
|
| 12 | +class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base { |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * @var string $_model_name |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * And the arguments accepted by EE_Form_Input_With_Options_Base |
| 44 | 44 | * @throws \EE_Error |
| 45 | 45 | */ |
| 46 | - public function __construct( $input_settings = array() ) { |
|
| 46 | + public function __construct($input_settings = array()) { |
|
| 47 | 47 | //needed input settings: |
| 48 | 48 | //select2_args |
| 49 | 49 | $this->_model_name = EEH_Array::is_set( |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $query_params = EEH_Array::is_set( |
| 56 | 56 | $input_settings, |
| 57 | 57 | 'query_params', |
| 58 | - array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ) |
|
| 58 | + array('limit' => 10, 'caps' => EEM_Base::caps_read_admin) |
|
| 59 | 59 | ); |
| 60 | 60 | $this->_value_field_name = EEH_Array::is_set( |
| 61 | 61 | $input_settings, |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $this->_display_field_name = EEH_Array::is_set( |
| 66 | 66 | $input_settings, |
| 67 | 67 | 'display_field_name', |
| 68 | - $model->get_a_field_of_type( 'EE_Text_Field_Base' )->get_name() |
|
| 68 | + $model->get_a_field_of_type('EE_Text_Field_Base')->get_name() |
|
| 69 | 69 | ); |
| 70 | 70 | $this->_add_validation_strategy( |
| 71 | 71 | new EE_Model_Matching_Query_Validation_Strategy( |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | //get resource endpoint |
| 79 | 79 | $rest_controller = new EventEspresso\core\libraries\rest_api\controllers\model\Read(); |
| 80 | - $rest_controller->set_requested_version( EED_Core_Rest_Api::latest_rest_api_version() ); |
|
| 81 | - $url = $rest_controller->get_versioned_link_to( EEH_Inflector::pluralize_and_lower( $this->_model_name ) ); |
|
| 80 | + $rest_controller->set_requested_version(EED_Core_Rest_Api::latest_rest_api_version()); |
|
| 81 | + $url = $rest_controller->get_versioned_link_to(EEH_Inflector::pluralize_and_lower($this->_model_name)); |
|
| 82 | 82 | $default_select2_args = array( |
| 83 | 83 | 'ajax' => array( |
| 84 | 84 | 'url' => $url, |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | 'delay' => '250', |
| 87 | 87 | 'data_interface' => 'EE_Select2_REST_API_Interface', |
| 88 | 88 | 'data_interface_args' => array( |
| 89 | - 'default_query_params' => (object)Model_Data_Translator::prepare_query_params_for_rest_api( |
|
| 89 | + 'default_query_params' => (object) Model_Data_Translator::prepare_query_params_for_rest_api( |
|
| 90 | 90 | $query_params, |
| 91 | 91 | $model |
| 92 | 92 | ), |
| 93 | 93 | 'display_field' => $this->_display_field_name, |
| 94 | 94 | 'value_field' => $this->_value_field_name, |
| 95 | - 'nonce' => wp_create_nonce( 'wp_rest' ) |
|
| 95 | + 'nonce' => wp_create_nonce('wp_rest') |
|
| 96 | 96 | ), |
| 97 | 97 | ), |
| 98 | 98 | 'cache' => true, |
@@ -100,10 +100,10 @@ discard block |
||
| 100 | 100 | ); |
| 101 | 101 | $select2_args = array_replace_recursive( |
| 102 | 102 | $default_select2_args, |
| 103 | - (array)EEH_Array::is_set( $input_settings, 'select2_args', array() ) |
|
| 103 | + (array) EEH_Array::is_set($input_settings, 'select2_args', array()) |
|
| 104 | 104 | ); |
| 105 | - $this->set_display_strategy( new EE_Select2_Display_Strategy( $select2_args ) ); |
|
| 106 | - parent::__construct( array(), $input_settings ); |
|
| 105 | + $this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args)); |
|
| 106 | + parent::__construct(array(), $input_settings); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
@@ -116,33 +116,33 @@ discard block |
||
| 116 | 116 | * @return void |
| 117 | 117 | * @throws \EE_Error |
| 118 | 118 | */ |
| 119 | - public function set_default( $value ) { |
|
| 119 | + public function set_default($value) { |
|
| 120 | 120 | |
| 121 | - $values_for_options = (array)$value; |
|
| 122 | - $value_field = $this->_get_model()->field_settings_for( $this->_value_field_name ); |
|
| 123 | - $display_field = $this->_get_model()->field_settings_for( $this->_display_field_name ); |
|
| 121 | + $values_for_options = (array) $value; |
|
| 122 | + $value_field = $this->_get_model()->field_settings_for($this->_value_field_name); |
|
| 123 | + $display_field = $this->_get_model()->field_settings_for($this->_display_field_name); |
|
| 124 | 124 | $display_values = $this->_get_model()->get_all_wpdb_results( |
| 125 | 125 | array( |
| 126 | 126 | array( |
| 127 | - $this->_value_field_name => array( 'IN', $values_for_options ) |
|
| 127 | + $this->_value_field_name => array('IN', $values_for_options) |
|
| 128 | 128 | ) |
| 129 | 129 | ), |
| 130 | 130 | ARRAY_A, |
| 131 | 131 | implode( |
| 132 | 132 | ',', |
| 133 | 133 | array( |
| 134 | - $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name, |
|
| 135 | - $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name |
|
| 134 | + $value_field->get_qualified_column().' AS '.$this->_value_field_name, |
|
| 135 | + $display_field->get_qualified_column().' AS '.$this->_display_field_name |
|
| 136 | 136 | ) |
| 137 | 137 | ) |
| 138 | 138 | ); |
| 139 | 139 | $select_options = array(); |
| 140 | - foreach( $display_values as $db_rows ) { |
|
| 141 | - $db_rows = (array)$db_rows; |
|
| 142 | - $select_options[ $db_rows[ $this->_value_field_name ] ] = $db_rows[ $this->_display_field_name ]; |
|
| 140 | + foreach ($display_values as $db_rows) { |
|
| 141 | + $db_rows = (array) $db_rows; |
|
| 142 | + $select_options[$db_rows[$this->_value_field_name]] = $db_rows[$this->_display_field_name]; |
|
| 143 | 143 | } |
| 144 | - $this->set_select_options( $select_options ); |
|
| 145 | - parent::set_default( $value ); |
|
| 144 | + $this->set_select_options($select_options); |
|
| 145 | + parent::set_default($value); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @throws EE_Error |
| 152 | 152 | */ |
| 153 | 153 | protected function _get_model() { |
| 154 | - if( ! EE_Registry::instance()->is_model_name( $this->_model_name ) ) { |
|
| 154 | + if ( ! EE_Registry::instance()->is_model_name($this->_model_name)) { |
|
| 155 | 155 | throw new EE_Error( |
| 156 | 156 | sprintf( |
| 157 | 157 | __( |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | ) |
| 163 | 163 | ); |
| 164 | 164 | } else { |
| 165 | - return EE_Registry::instance()->load_model( $this->_model_name ); |
|
| 165 | + return EE_Registry::instance()->load_model($this->_model_name); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |