@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers\config; |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * @param \WP_REST_Request $request |
22 | 22 | * @return \EE_Config|\WP_Error |
23 | 23 | */ |
24 | - public static function handle_request( \WP_REST_Request $request) { |
|
24 | + public static function handle_request(\WP_REST_Request $request) { |
|
25 | 25 | $cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap(); |
26 | - if( \EE_Capabilities::instance()->current_user_can( $cap, 'read_over_api' ) ){ |
|
26 | + if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) { |
|
27 | 27 | return \EE_Config::instance(); |
28 | - }else{ |
|
28 | + } else { |
|
29 | 29 | return new \WP_Error( |
30 | 30 | 'cannot_read_config', |
31 | 31 | sprintf( |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | ), |
36 | 36 | $cap |
37 | 37 | ), |
38 | - array( 'status' => 403 ) |
|
38 | + array('status' => 403) |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | } |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | * @param \WP_REST_Request $request |
46 | 46 | * @return \EE_Config|\WP_Error |
47 | 47 | */ |
48 | - public static function handle_request_site_info( \WP_REST_Request $request) { |
|
48 | + public static function handle_request_site_info(\WP_REST_Request $request) { |
|
49 | 49 | return array( |
50 | 50 | 'default_timezone' => array( |
51 | 51 | 'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(), |
52 | - 'string' => get_option( 'timezone_string' ), |
|
52 | + 'string' => get_option('timezone_string'), |
|
53 | 53 | 'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
54 | 54 | ), |
55 | 55 | 'default_currency' => \EE_Config::instance()->currency |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | |
146 | 146 | /** |
147 | - * @return null |
|
147 | + * @return EE_Line_Item_Display |
|
148 | 148 | */ |
149 | 149 | public function line_item_display() { |
150 | 150 | return $this->line_item_display; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | |
155 | 155 | /** |
156 | - * @param null $line_item_display |
|
156 | + * @param EE_Line_Item_Display $line_item_display |
|
157 | 157 | */ |
158 | 158 | public function set_line_item_display( $line_item_display ) { |
159 | 159 | $this->line_item_display = $line_item_display; |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | * _apply_registration_payments_to_amount_owing |
840 | 840 | * |
841 | 841 | * @access protected |
842 | - * @param array $registrations |
|
842 | + * @param EE_Base_Class[] $registrations |
|
843 | 843 | */ |
844 | 844 | protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
845 | 845 | $payments = array(); |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | * get_billing_form_html_for_payment_method |
1113 | 1113 | * |
1114 | 1114 | * @access public |
1115 | - * @return string |
|
1115 | + * @return boolean |
|
1116 | 1116 | * @throws \EE_Error |
1117 | 1117 | */ |
1118 | 1118 | public function get_billing_form_html_for_payment_method() { |
@@ -1176,7 +1176,7 @@ discard block |
||
1176 | 1176 | * |
1177 | 1177 | * @access private |
1178 | 1178 | * @param EE_Payment_Method $payment_method |
1179 | - * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML |
|
1179 | + * @return EE_Billing_Info_Form |
|
1180 | 1180 | * @throws \EE_Error |
1181 | 1181 | */ |
1182 | 1182 | private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | * switch_payment_method |
1281 | 1281 | * |
1282 | 1282 | * @access public |
1283 | - * @return string |
|
1283 | + * @return boolean |
|
1284 | 1284 | * @throws \EE_Error |
1285 | 1285 | */ |
1286 | 1286 | public function switch_payment_method() { |
@@ -1487,7 +1487,7 @@ discard block |
||
1487 | 1487 | /** |
1488 | 1488 | * process_reg_step |
1489 | 1489 | * |
1490 | - * @return boolean |
|
1490 | + * @return null|boolean |
|
1491 | 1491 | * @throws \EE_Error |
1492 | 1492 | */ |
1493 | 1493 | public function process_reg_step() { |
@@ -1613,7 +1613,7 @@ discard block |
||
1613 | 1613 | * update_reg_step |
1614 | 1614 | * this is the final step after a user revisits the site to retry a payment |
1615 | 1615 | * |
1616 | - * @return boolean |
|
1616 | + * @return null|boolean |
|
1617 | 1617 | * @throws \EE_Error |
1618 | 1618 | */ |
1619 | 1619 | public function update_reg_step() { |
@@ -1981,7 +1981,7 @@ discard block |
||
1981 | 1981 | * |
1982 | 1982 | * @access private |
1983 | 1983 | * @type EE_Payment_Method $payment_method |
1984 | - * @return mixed EE_Payment | boolean |
|
1984 | + * @return EE_Payment|null EE_Payment | boolean |
|
1985 | 1985 | * @throws \EE_Error |
1986 | 1986 | */ |
1987 | 1987 | private function _attempt_payment( EE_Payment_Method $payment_method ) { |
@@ -2112,7 +2112,7 @@ discard block |
||
2112 | 2112 | * _post_payment_processing |
2113 | 2113 | * |
2114 | 2114 | * @access private |
2115 | - * @param EE_Payment|bool $payment |
|
2115 | + * @param EE_Payment $payment |
|
2116 | 2116 | * @return bool |
2117 | 2117 | * @throws \EE_Error |
2118 | 2118 | */ |
@@ -2301,7 +2301,7 @@ discard block |
||
2301 | 2301 | * or present the payment options again |
2302 | 2302 | * |
2303 | 2303 | * @access private |
2304 | - * @return EE_Payment | FALSE |
|
2304 | + * @return boolean | FALSE |
|
2305 | 2305 | * @throws \EE_Error |
2306 | 2306 | */ |
2307 | 2307 | public function process_gateway_response() { |
@@ -2434,8 +2434,8 @@ discard block |
||
2434 | 2434 | * _redirect_wayward_request |
2435 | 2435 | * |
2436 | 2436 | * @access private |
2437 | - * @param \EE_Registration|null $primary_registrant |
|
2438 | - * @return bool |
|
2437 | + * @param EE_Registration $primary_registrant |
|
2438 | + * @return false|null |
|
2439 | 2439 | * @throws \EE_Error |
2440 | 2440 | */ |
2441 | 2441 | private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
@@ -467,38 +467,38 @@ discard block |
||
467 | 467 | * @throws \EE_Error |
468 | 468 | */ |
469 | 469 | public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
470 | - // registrations per event |
|
470 | + // registrations per event |
|
471 | 471 | $event_reg_count = array(); |
472 | 472 | // spaces left per event |
473 | 473 | $event_spaces_remaining = array(); |
474 | - // tickets left sorted by ID |
|
475 | - $tickets_remaining = array(); |
|
476 | - // registrations that have lost their space |
|
474 | + // tickets left sorted by ID |
|
475 | + $tickets_remaining = array(); |
|
476 | + // registrations that have lost their space |
|
477 | 477 | $ejected_registrations = array(); |
478 | 478 | foreach ( $registrations as $REG_ID => $registration ) { |
479 | 479 | if ( $registration->status_ID() === EEM_Registration::status_id_approved ) { |
480 | 480 | continue; |
481 | 481 | } |
482 | 482 | $EVT_ID = $registration->event_ID(); |
483 | - $ticket = $registration->ticket(); |
|
484 | - if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
485 | - $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
486 | - } |
|
487 | - if ($tickets_remaining[$ticket->ID()] > 0) { |
|
488 | - if ( ! isset($event_reg_count[$EVT_ID])) { |
|
489 | - $event_reg_count[$EVT_ID] = 0; |
|
490 | - } |
|
491 | - $event_reg_count[$EVT_ID]++; |
|
492 | - if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
493 | - $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
494 | - } |
|
495 | - } |
|
483 | + $ticket = $registration->ticket(); |
|
484 | + if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
485 | + $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
486 | + } |
|
487 | + if ($tickets_remaining[$ticket->ID()] > 0) { |
|
488 | + if ( ! isset($event_reg_count[$EVT_ID])) { |
|
489 | + $event_reg_count[$EVT_ID] = 0; |
|
490 | + } |
|
491 | + $event_reg_count[$EVT_ID]++; |
|
492 | + if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
493 | + $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
494 | + } |
|
495 | + } |
|
496 | 496 | if ( |
497 | 497 | $revisit |
498 | 498 | && ( |
499 | - $tickets_remaining[$ticket->ID()] === 0 |
|
500 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
501 | - ) |
|
499 | + $tickets_remaining[$ticket->ID()] === 0 |
|
500 | + || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
501 | + ) |
|
502 | 502 | ) { |
503 | 503 | $ejected_registrations[ $REG_ID ] = $registration->event(); |
504 | 504 | if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
@@ -573,9 +573,9 @@ discard block |
||
573 | 573 | 'layout_strategy' => new EE_Template_Layout( |
574 | 574 | array( |
575 | 575 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
576 | - . $this->_slug |
|
577 | - . DS |
|
578 | - . 'sold_out_events.template.php', |
|
576 | + . $this->_slug |
|
577 | + . DS |
|
578 | + . 'sold_out_events.template.php', |
|
579 | 579 | 'template_args' => apply_filters( |
580 | 580 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
581 | 581 | array( |
@@ -626,9 +626,9 @@ discard block |
||
626 | 626 | 'layout_strategy' => new EE_Template_Layout( |
627 | 627 | array( |
628 | 628 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
629 | - . $this->_slug |
|
630 | - . DS |
|
631 | - . 'sold_out_events.template.php', |
|
629 | + . $this->_slug |
|
630 | + . DS |
|
631 | + . 'sold_out_events.template.php', |
|
632 | 632 | 'template_args' => apply_filters( |
633 | 633 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args', |
634 | 634 | array( |
@@ -680,9 +680,9 @@ discard block |
||
680 | 680 | 'layout_strategy' => new EE_Template_Layout( |
681 | 681 | array( |
682 | 682 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
683 | - . $this->_slug |
|
684 | - . DS |
|
685 | - . 'events_requiring_pre_approval.template.php', // layout_template |
|
683 | + . $this->_slug |
|
684 | + . DS |
|
685 | + . 'events_requiring_pre_approval.template.php', // layout_template |
|
686 | 686 | 'template_args' => apply_filters( |
687 | 687 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
688 | 688 | array( |
@@ -724,9 +724,9 @@ discard block |
||
724 | 724 | 'layout_strategy' => new EE_Template_Layout( |
725 | 725 | array( |
726 | 726 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
727 | - . $this->_slug |
|
728 | - . DS |
|
729 | - . 'no_payment_required.template.php', // layout_template |
|
727 | + . $this->_slug |
|
728 | + . DS |
|
729 | + . 'no_payment_required.template.php', // layout_template |
|
730 | 730 | 'template_args' => apply_filters( |
731 | 731 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
732 | 732 | array( |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
957 | 957 | } |
958 | 958 | $payment_methods_billing_info[ $payment_method->slug() |
959 | - . '-info' ] = $this->_payment_method_billing_info( |
|
959 | + . '-info' ] = $this->_payment_method_billing_info( |
|
960 | 960 | $payment_method |
961 | 961 | ); |
962 | 962 | } |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | // fill form with attendee info if applicable |
1145 | 1145 | if ( |
1146 | 1146 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
1147 | - && $this->checkout->transaction_has_primary_registrant() |
|
1147 | + && $this->checkout->transaction_has_primary_registrant() |
|
1148 | 1148 | ) { |
1149 | 1149 | $payment_method_billing_form->populate_from_attendee( |
1150 | 1150 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | // and debug content |
1154 | 1154 | if ( |
1155 | 1155 | $payment_method_billing_form instanceof EE_Billing_Info_Form |
1156 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1156 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1157 | 1157 | ) { |
1158 | 1158 | $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1159 | 1159 | $payment_method_billing_form |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | } |
1313 | 1313 | // fill form with attendee info if applicable |
1314 | 1314 | if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
1315 | - && $this->checkout->transaction_has_primary_registrant() |
|
1315 | + && $this->checkout->transaction_has_primary_registrant() |
|
1316 | 1316 | ) { |
1317 | 1317 | $this->checkout->billing_form->populate_from_attendee( |
1318 | 1318 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -1320,7 +1320,7 @@ discard block |
||
1320 | 1320 | } |
1321 | 1321 | // and debug content |
1322 | 1322 | if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
1323 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1323 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1324 | 1324 | ) { |
1325 | 1325 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1326 | 1326 | $this->checkout->billing_form |
@@ -1454,8 +1454,8 @@ discard block |
||
1454 | 1454 | } |
1455 | 1455 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1456 | 1456 | if ( ! empty( $attendee_data['ATT_fname'] ) |
1457 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1458 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1457 | + && ! empty( $attendee_data['ATT_lname'] ) |
|
1458 | + && ! empty( $attendee_data['ATT_email'] ) |
|
1459 | 1459 | ) { |
1460 | 1460 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1461 | 1461 | array( |
@@ -1697,7 +1697,7 @@ discard block |
||
1697 | 1697 | $payment_status = $payment->status(); |
1698 | 1698 | if ( |
1699 | 1699 | $payment_status === EEM_Payment::status_id_approved |
1700 | - || $payment_status === EEM_Payment::status_id_pending |
|
1700 | + || $payment_status === EEM_Payment::status_id_pending |
|
1701 | 1701 | ) { |
1702 | 1702 | return true; |
1703 | 1703 | } else { |
@@ -1885,8 +1885,8 @@ discard block |
||
1885 | 1885 | return false; |
1886 | 1886 | } |
1887 | 1887 | if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
1888 | - instanceof |
|
1889 | - EE_Attendee |
|
1888 | + instanceof |
|
1889 | + EE_Attendee |
|
1890 | 1890 | ) { |
1891 | 1891 | EE_Error::add_error( |
1892 | 1892 | sprintf( |
@@ -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 | |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @param EE_Checkout $checkout |
128 | 128 | */ |
129 | - public function __construct( EE_Checkout $checkout ) { |
|
129 | + public function __construct(EE_Checkout $checkout) { |
|
130 | 130 | $this->_slug = 'payment_options'; |
131 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
132 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
131 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
132 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
133 | 133 | $this->checkout = $checkout; |
134 | 134 | $this->_reset_success_message(); |
135 | 135 | $this->set_instructions( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @param null $line_item_display |
156 | 156 | */ |
157 | - public function set_line_item_display( $line_item_display ) { |
|
157 | + public function set_line_item_display($line_item_display) { |
|
158 | 158 | $this->line_item_display = $line_item_display; |
159 | 159 | } |
160 | 160 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * @param boolean $handle_IPN_in_this_request |
174 | 174 | */ |
175 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
176 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
175 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
176 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | public function enqueue_styles_and_scripts() { |
209 | 209 | $transaction = $this->checkout->transaction; |
210 | 210 | //if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
211 | - if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) { |
|
211 | + if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | - foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) { |
|
214 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) { |
|
215 | 215 | $type_obj = $payment_method->type_obj(); |
216 | - if( $type_obj instanceof EE_PMT_Base ) { |
|
217 | - $billing_form = $type_obj->generate_new_billing_form( $transaction ); |
|
218 | - if( $billing_form instanceof EE_Form_Section_Proper ) { |
|
216 | + if ($type_obj instanceof EE_PMT_Base) { |
|
217 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
218 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
219 | 219 | $billing_form->enqueue_js(); |
220 | 220 | } |
221 | 221 | } |
@@ -240,20 +240,20 @@ discard block |
||
240 | 240 | // $ 0.00 transactions (no payment required) |
241 | 241 | ! $this->checkout->payment_required() |
242 | 242 | // but do NOT remove if current action being called belongs to this reg step |
243 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
243 | + && ! is_callable(array($this, $this->checkout->action)) |
|
244 | 244 | && ! $this->completed() |
245 | 245 | ) { |
246 | 246 | // and if so, then we no longer need the Payment Options step |
247 | - if ( $this->is_current_step() ) { |
|
247 | + if ($this->is_current_step()) { |
|
248 | 248 | $this->checkout->generate_reg_form = false; |
249 | 249 | } |
250 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
250 | + $this->checkout->remove_reg_step($this->_slug); |
|
251 | 251 | // DEBUG LOG |
252 | 252 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | // load EEM_Payment_Method |
256 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
256 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
257 | 257 | // get all active payment methods |
258 | 258 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
259 | 259 | $this->checkout->transaction, |
@@ -280,15 +280,15 @@ discard block |
||
280 | 280 | $insufficient_spaces_available = array(); |
281 | 281 | $reg_count = 0; |
282 | 282 | // loop thru registrations to gather info |
283 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
283 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
284 | 284 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
285 | 285 | $registrations, |
286 | 286 | $this->checkout->revisit |
287 | 287 | ); |
288 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
288 | + foreach ($registrations as $REG_ID => $registration) { |
|
289 | 289 | // has this registration lost it's space ? |
290 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
291 | - $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
290 | + if (isset($ejected_registrations[$REG_ID])) { |
|
291 | + $insufficient_spaces_available[$registration->event()->ID()] = $registration->event(); |
|
292 | 292 | continue; |
293 | 293 | } |
294 | 294 | /** @var $registration EE_Registration */ |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | && $registration->status_ID() === EEM_Registration::status_id_approved |
301 | 301 | ) |
302 | 302 | ) { |
303 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true ) ) { |
|
303 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
304 | 304 | // add event to list of events that are sold out |
305 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
305 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
306 | 306 | do_action( |
307 | 307 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
308 | 308 | $registration->event(), |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | continue; |
312 | 312 | } |
313 | 313 | // event requires admin approval |
314 | - if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) { |
|
314 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
315 | 315 | // add event to list of events with pre-approval reg status |
316 | - $registrations_requiring_pre_approval[ $REG_ID ] = $registration; |
|
316 | + $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
317 | 317 | do_action( |
318 | 318 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
319 | 319 | $registration->event(), |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | } |
323 | 323 | } |
324 | 324 | // are they allowed to pay now and is there monies owing? |
325 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
326 | - $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
325 | + if ($registration->owes_monies_and_can_pay()) { |
|
326 | + $registrations_requiring_payment[$REG_ID] = $registration; |
|
327 | 327 | do_action( |
328 | 328 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
329 | 329 | $registration->event(), |
@@ -334,29 +334,29 @@ discard block |
||
334 | 334 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
335 | 335 | && $registration->ticket()->is_free() |
336 | 336 | ) { |
337 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
337 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | $subsections = array(); |
341 | 341 | // now decide which template to load |
342 | - if ( ! empty( $sold_out_events ) ) { |
|
343 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
342 | + if ( ! empty($sold_out_events)) { |
|
343 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
344 | 344 | } |
345 | - if ( ! empty( $insufficient_spaces_available ) ) { |
|
345 | + if ( ! empty($insufficient_spaces_available)) { |
|
346 | 346 | $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
347 | 347 | $insufficient_spaces_available |
348 | 348 | ); |
349 | 349 | } |
350 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
350 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
351 | 351 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
352 | 352 | $registrations_requiring_pre_approval |
353 | 353 | ); |
354 | 354 | } |
355 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
356 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
355 | + if ( ! empty($registrations_for_free_events)) { |
|
356 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
357 | 357 | } |
358 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
359 | - if ( $this->checkout->amount_owing > 0 ) { |
|
358 | + if ( ! empty($registrations_requiring_payment)) { |
|
359 | + if ($this->checkout->amount_owing > 0) { |
|
360 | 360 | // autoload Line_Item_Display classes |
361 | 361 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
362 | 362 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -369,15 +369,15 @@ discard block |
||
369 | 369 | /** @var EE_Line_Item $filtered_line_item_tree */ |
370 | 370 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
371 | 371 | EEH_Autoloader::register_line_item_display_autoloaders(); |
372 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
372 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
373 | 373 | $subsections['payment_options'] = $this->_display_payment_options( |
374 | 374 | $this->line_item_display->display_line_item( |
375 | 375 | $filtered_line_item_tree, |
376 | - array( 'registrations' => $registrations ) |
|
376 | + array('registrations' => $registrations) |
|
377 | 377 | ) |
378 | 378 | ); |
379 | 379 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
380 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
380 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
381 | 381 | } |
382 | 382 | } else { |
383 | 383 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return \EE_Line_Item_Filter_Collection |
409 | 409 | * @throws \EE_Error |
410 | 410 | */ |
411 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
411 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
412 | 412 | $line_item_filter_collection->add( |
413 | 413 | new EE_Billable_Line_Item_Filter( |
414 | 414 | EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations( |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | ) |
419 | 419 | ) |
420 | 420 | ); |
421 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
421 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
422 | 422 | return $line_item_filter_collection; |
423 | 423 | } |
424 | 424 | |
@@ -434,15 +434,15 @@ discard block |
||
434 | 434 | * @return \EE_Registration[] |
435 | 435 | * @throws \EE_Error |
436 | 436 | */ |
437 | - public static function remove_ejected_registrations( array $registrations ) { |
|
437 | + public static function remove_ejected_registrations(array $registrations) { |
|
438 | 438 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
439 | 439 | $registrations, |
440 | 440 | EE_Registry::instance()->SSN->checkout()->revisit |
441 | 441 | ); |
442 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
442 | + foreach ($registrations as $REG_ID => $registration) { |
|
443 | 443 | // has this registration lost it's space ? |
444 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
445 | - unset( $registrations[ $REG_ID ] ); |
|
444 | + if (isset($ejected_registrations[$REG_ID])) { |
|
445 | + unset($registrations[$REG_ID]); |
|
446 | 446 | continue; |
447 | 447 | } |
448 | 448 | } |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | * @return array |
466 | 466 | * @throws \EE_Error |
467 | 467 | */ |
468 | - public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
|
468 | + public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) { |
|
469 | 469 | // registrations per event |
470 | 470 | $event_reg_count = array(); |
471 | 471 | // spaces left per event |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | $tickets_remaining = array(); |
475 | 475 | // registrations that have lost their space |
476 | 476 | $ejected_registrations = array(); |
477 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
478 | - if ( $registration->status_ID() === EEM_Registration::status_id_approved ) { |
|
477 | + foreach ($registrations as $REG_ID => $registration) { |
|
478 | + if ($registration->status_ID() === EEM_Registration::status_id_approved) { |
|
479 | 479 | continue; |
480 | 480 | } |
481 | 481 | $EVT_ID = $registration->event_ID(); |
@@ -496,13 +496,13 @@ discard block |
||
496 | 496 | $revisit |
497 | 497 | && ( |
498 | 498 | $tickets_remaining[$ticket->ID()] === 0 |
499 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
499 | + || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID] |
|
500 | 500 | ) |
501 | 501 | ) { |
502 | - $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
503 | - if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
|
502 | + $ejected_registrations[$REG_ID] = $registration->event(); |
|
503 | + if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
|
504 | 504 | /** @type EE_Registration_Processor $registration_processor */ |
505 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
505 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
506 | 506 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
507 | 507 | $registration_processor->manually_update_registration_status( |
508 | 508 | $registration, |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | * @return void |
538 | 538 | */ |
539 | 539 | protected function _hide_reg_step_submit_button_if_revisit() { |
540 | - if ( $this->checkout->revisit ) { |
|
541 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
540 | + if ($this->checkout->revisit) { |
|
541 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
@@ -552,13 +552,13 @@ discard block |
||
552 | 552 | * @return \EE_Form_Section_Proper |
553 | 553 | * @throws \EE_Error |
554 | 554 | */ |
555 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
555 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
556 | 556 | // set some defaults |
557 | 557 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
558 | 558 | $sold_out_events = ''; |
559 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
559 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
560 | 560 | $sold_out_events .= EEH_HTML::li( |
561 | - EEH_HTML::span( ' ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
561 | + EEH_HTML::span(' '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
562 | 562 | ); |
563 | 563 | } |
564 | 564 | return new EE_Form_Section_Proper( |
@@ -605,14 +605,14 @@ discard block |
||
605 | 605 | * @return \EE_Form_Section_Proper |
606 | 606 | * @throws \EE_Error |
607 | 607 | */ |
608 | - private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) { |
|
608 | + private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) { |
|
609 | 609 | // set some defaults |
610 | 610 | $this->checkout->selected_method_of_payment = 'invoice'; |
611 | 611 | $insufficient_space_events = ''; |
612 | - foreach ( $insufficient_spaces_events_array as $event ) { |
|
613 | - if ( $event instanceof EE_Event ) { |
|
612 | + foreach ($insufficient_spaces_events_array as $event) { |
|
613 | + if ($event instanceof EE_Event) { |
|
614 | 614 | $insufficient_space_events .= EEH_HTML::li( |
615 | - EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
615 | + EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
616 | 616 | ); |
617 | 617 | } |
618 | 618 | } |
@@ -656,17 +656,17 @@ discard block |
||
656 | 656 | * @return \EE_Form_Section_Proper |
657 | 657 | * @throws \EE_Error |
658 | 658 | */ |
659 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
659 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
660 | 660 | $events_requiring_pre_approval = ''; |
661 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
662 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
663 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
661 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
662 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
663 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
664 | 664 | EEH_HTML::span( |
665 | 665 | '', |
666 | 666 | '', |
667 | 667 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
668 | 668 | ) |
669 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
669 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
670 | 670 | ); |
671 | 671 | } |
672 | 672 | } |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | 'template_args' => apply_filters( |
686 | 686 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
687 | 687 | array( |
688 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
688 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
689 | 689 | 'events_requiring_pre_approval_msg' => apply_filters( |
690 | 690 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
691 | 691 | __( |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | * @return \EE_Form_Section_Proper |
711 | 711 | * @throws \EE_Error |
712 | 712 | */ |
713 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
713 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
714 | 714 | // set some defaults |
715 | 715 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
716 | 716 | // generate no_payment_required form |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | 'ticket_count' => array(), |
735 | 735 | 'registrations_for_free_events' => $registrations_for_free_events, |
736 | 736 | 'no_payment_required_msg' => EEH_HTML::p( |
737 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
737 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
738 | 738 | ) |
739 | 739 | ) |
740 | 740 | ), |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * @return \EE_Form_Section_Proper |
754 | 754 | * @throws \EE_Error |
755 | 755 | */ |
756 | - private function _display_payment_options( $transaction_details = '' ) { |
|
756 | + private function _display_payment_options($transaction_details = '') { |
|
757 | 757 | // has method_of_payment been set by no-js user? |
758 | 758 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
759 | 759 | // build payment options form |
@@ -765,18 +765,18 @@ discard block |
||
765 | 765 | 'before_payment_options' => apply_filters( |
766 | 766 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
767 | 767 | new EE_Form_Section_Proper( |
768 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
768 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
769 | 769 | ) |
770 | 770 | ), |
771 | 771 | 'payment_options' => $this->_setup_payment_options(), |
772 | 772 | 'after_payment_options' => apply_filters( |
773 | 773 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
774 | 774 | new EE_Form_Section_Proper( |
775 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
775 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
776 | 776 | ) |
777 | 777 | ), |
778 | 778 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
779 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( false ) |
|
779 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(false) |
|
780 | 780 | ), |
781 | 781 | 'layout_strategy' => new EE_Template_Layout( |
782 | 782 | array( |
@@ -805,10 +805,10 @@ discard block |
||
805 | 805 | * @return \EE_Form_Section_Proper |
806 | 806 | * @throws \EE_Error |
807 | 807 | */ |
808 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
808 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
809 | 809 | return new EE_Form_Section_Proper( |
810 | 810 | array( |
811 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
811 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
812 | 812 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
813 | 813 | 'subsections' => array( |
814 | 814 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -840,16 +840,16 @@ discard block |
||
840 | 840 | * @access protected |
841 | 841 | * @param array $registrations |
842 | 842 | */ |
843 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
843 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
844 | 844 | $payments = array(); |
845 | - foreach ( $registrations as $registration ) { |
|
846 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
845 | + foreach ($registrations as $registration) { |
|
846 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
847 | 847 | $payments += $registration->registration_payments(); |
848 | 848 | } |
849 | 849 | } |
850 | - if ( ! empty( $payments ) ) { |
|
851 | - foreach ( $payments as $payment ) { |
|
852 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
850 | + if ( ! empty($payments)) { |
|
851 | + foreach ($payments as $payment) { |
|
852 | + if ($payment instanceof EE_Registration_Payment) { |
|
853 | 853 | $this->checkout->amount_owing -= $payment->amount(); |
854 | 854 | } |
855 | 855 | } |
@@ -865,11 +865,11 @@ discard block |
||
865 | 865 | * @param bool $force_reset |
866 | 866 | * @return void |
867 | 867 | */ |
868 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
868 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
869 | 869 | $reset_payment_method = $force_reset |
870 | 870 | ? true |
871 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
872 | - if ( $reset_payment_method ) { |
|
871 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
872 | + if ($reset_payment_method) { |
|
873 | 873 | $this->checkout->selected_method_of_payment = null; |
874 | 874 | $this->checkout->payment_method = null; |
875 | 875 | $this->checkout->billing_form = null; |
@@ -888,12 +888,12 @@ discard block |
||
888 | 888 | * @param string $selected_method_of_payment |
889 | 889 | * @return void |
890 | 890 | */ |
891 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
892 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
891 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
892 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
893 | 893 | ? $selected_method_of_payment |
894 | 894 | : $this->checkout->selected_method_of_payment; |
895 | 895 | EE_Registry::instance()->SSN->set_session_data( |
896 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
896 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
897 | 897 | ); |
898 | 898 | } |
899 | 899 | |
@@ -909,19 +909,19 @@ discard block |
||
909 | 909 | // load payment method classes |
910 | 910 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
911 | 911 | // switch up header depending on number of available payment methods |
912 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
912 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
913 | 913 | ? apply_filters( |
914 | 914 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
915 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
915 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
916 | 916 | ) |
917 | 917 | : apply_filters( |
918 | 918 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
919 | - __( 'Method of Payment', 'event_espresso' ) |
|
919 | + __('Method of Payment', 'event_espresso') |
|
920 | 920 | ); |
921 | 921 | $available_payment_methods = array( |
922 | 922 | // display the "Payment Method" header |
923 | 923 | 'payment_method_header' => new EE_Form_Section_HTML( |
924 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
924 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
925 | 925 | ) |
926 | 926 | ); |
927 | 927 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -930,32 +930,32 @@ discard block |
||
930 | 930 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
931 | 931 | $payment_methods_billing_info = array( |
932 | 932 | new EE_Form_Section_HTML( |
933 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
933 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
934 | 934 | ) |
935 | 935 | ); |
936 | 936 | // loop through payment methods |
937 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
938 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
937 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
938 | + if ($payment_method instanceof EE_Payment_Method) { |
|
939 | 939 | $payment_method_button = EEH_HTML::img( |
940 | 940 | $payment_method->button_url(), |
941 | 941 | $payment_method->name(), |
942 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
942 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
943 | 943 | 'spco-payment-method-btn-img' |
944 | 944 | ); |
945 | 945 | // check if any payment methods are set as default |
946 | 946 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
947 | 947 | if ( |
948 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
949 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
948 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
949 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
950 | 950 | ) { |
951 | 951 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
952 | 952 | $this->_save_selected_method_of_payment(); |
953 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
953 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
954 | 954 | } else { |
955 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
955 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
956 | 956 | } |
957 | - $payment_methods_billing_info[ $payment_method->slug() |
|
958 | - . '-info' ] = $this->_payment_method_billing_info( |
|
957 | + $payment_methods_billing_info[$payment_method->slug() |
|
958 | + . '-info'] = $this->_payment_method_billing_info( |
|
959 | 959 | $payment_method |
960 | 960 | ); |
961 | 961 | } |
@@ -985,12 +985,12 @@ discard block |
||
985 | 985 | * @return EE_Payment_Method[] |
986 | 986 | */ |
987 | 987 | protected function _get_available_payment_methods() { |
988 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
988 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
989 | 989 | return $this->checkout->available_payment_methods; |
990 | 990 | } |
991 | 991 | $available_payment_methods = array(); |
992 | 992 | // load EEM_Payment_Method |
993 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
993 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
994 | 994 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
995 | 995 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
996 | 996 | // get all active payment methods |
@@ -998,9 +998,9 @@ discard block |
||
998 | 998 | $this->checkout->transaction, |
999 | 999 | EEM_Payment_Method::scope_cart |
1000 | 1000 | ); |
1001 | - foreach ( $payment_methods as $payment_method ) { |
|
1002 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
1003 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
1001 | + foreach ($payment_methods as $payment_method) { |
|
1002 | + if ($payment_method instanceof EE_Payment_Method) { |
|
1003 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
1004 | 1004 | } |
1005 | 1005 | } |
1006 | 1006 | return $available_payment_methods; |
@@ -1015,14 +1015,14 @@ discard block |
||
1015 | 1015 | * @param array $available_payment_method_options |
1016 | 1016 | * @return \EE_Form_Section_Proper |
1017 | 1017 | */ |
1018 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
1018 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
1019 | 1019 | // generate inputs |
1020 | 1020 | return new EE_Form_Section_Proper( |
1021 | 1021 | array( |
1022 | 1022 | 'html_id' => 'ee-available-payment-method-inputs', |
1023 | 1023 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1024 | 1024 | 'subsections' => array( |
1025 | - '' => new EE_Radio_Button_Input ( |
|
1025 | + '' => new EE_Radio_Button_Input( |
|
1026 | 1026 | $available_payment_method_options, |
1027 | 1027 | array( |
1028 | 1028 | 'html_name' => 'selected_method_of_payment', |
@@ -1047,28 +1047,28 @@ discard block |
||
1047 | 1047 | * @return \EE_Form_Section_Proper |
1048 | 1048 | * @throws \EE_Error |
1049 | 1049 | */ |
1050 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
1050 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
1051 | 1051 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
1052 | 1052 | ? true |
1053 | 1053 | : false; |
1054 | 1054 | // generate the billing form for payment method |
1055 | 1055 | $billing_form = $currently_selected |
1056 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
1056 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
1057 | 1057 | : new EE_Form_Section_HTML(); |
1058 | 1058 | $this->checkout->billing_form = $currently_selected |
1059 | 1059 | ? $billing_form |
1060 | 1060 | : $this->checkout->billing_form; |
1061 | 1061 | // it's all in the details |
1062 | 1062 | $info_html = EEH_HTML::h3( |
1063 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
1063 | + __('Important information regarding your payment', 'event_espresso'), |
|
1064 | 1064 | '', |
1065 | 1065 | 'spco-payment-method-hdr' |
1066 | 1066 | ); |
1067 | 1067 | // add some info regarding the step, either from what's saved in the admin, |
1068 | 1068 | // or a default string depending on whether the PM has a billing form or not |
1069 | - if ( $payment_method->description() ) { |
|
1069 | + if ($payment_method->description()) { |
|
1070 | 1070 | $payment_method_info = $payment_method->description(); |
1071 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1071 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
1072 | 1072 | $payment_method_info = sprintf( |
1073 | 1073 | __( |
1074 | 1074 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | ); |
1079 | 1079 | } else { |
1080 | 1080 | $payment_method_info = sprintf( |
1081 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
1081 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
1082 | 1082 | $this->submit_button_text() |
1083 | 1083 | ); |
1084 | 1084 | } |
@@ -1092,13 +1092,13 @@ discard block |
||
1092 | 1092 | ); |
1093 | 1093 | return new EE_Form_Section_Proper( |
1094 | 1094 | array( |
1095 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
1095 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
1096 | 1096 | 'html_class' => 'spco-payment-method-info-dv', |
1097 | 1097 | // only display the selected or default PM |
1098 | 1098 | 'html_style' => $currently_selected ? '' : 'display:none;', |
1099 | 1099 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1100 | 1100 | 'subsections' => array( |
1101 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
1101 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
1102 | 1102 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
1103 | 1103 | ) |
1104 | 1104 | ) |
@@ -1116,15 +1116,15 @@ discard block |
||
1116 | 1116 | */ |
1117 | 1117 | public function get_billing_form_html_for_payment_method() { |
1118 | 1118 | // how have they chosen to pay? |
1119 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1119 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1120 | 1120 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1121 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1121 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1122 | 1122 | return false; |
1123 | 1123 | } |
1124 | - if ( apply_filters( |
|
1124 | + if (apply_filters( |
|
1125 | 1125 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1126 | 1126 | false |
1127 | - ) ) { |
|
1127 | + )) { |
|
1128 | 1128 | EE_Error::add_success( |
1129 | 1129 | apply_filters( |
1130 | 1130 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | ); |
1140 | 1140 | } |
1141 | 1141 | // now generate billing form for selected method of payment |
1142 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1142 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1143 | 1143 | // fill form with attendee info if applicable |
1144 | 1144 | if ( |
1145 | 1145 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -1161,10 +1161,10 @@ discard block |
||
1161 | 1161 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
1162 | 1162 | ? $payment_method_billing_form->get_html() |
1163 | 1163 | : ''; |
1164 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
1164 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
1165 | 1165 | // localize validation rules for main form |
1166 | 1166 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
1167 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1167 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1168 | 1168 | return true; |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1178,18 +1178,18 @@ discard block |
||
1178 | 1178 | * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML |
1179 | 1179 | * @throws \EE_Error |
1180 | 1180 | */ |
1181 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
1181 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
1182 | 1182 | $billing_form = $payment_method->type_obj()->billing_form( |
1183 | 1183 | $this->checkout->transaction, |
1184 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
1184 | + array('amount_owing' => $this->checkout->amount_owing) |
|
1185 | 1185 | ); |
1186 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1186 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
1187 | 1187 | if ( |
1188 | 1188 | apply_filters( |
1189 | 1189 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1190 | 1190 | false |
1191 | 1191 | ) |
1192 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
1192 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
1193 | 1193 | ) { |
1194 | 1194 | EE_Error::add_success( |
1195 | 1195 | apply_filters( |
@@ -1231,15 +1231,15 @@ discard block |
||
1231 | 1231 | $request_param = 'selected_method_of_payment' |
1232 | 1232 | ) { |
1233 | 1233 | // is selected_method_of_payment set in the request ? |
1234 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
1235 | - if ( $selected_method_of_payment ) { |
|
1234 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
1235 | + if ($selected_method_of_payment) { |
|
1236 | 1236 | // sanitize it |
1237 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
1238 | - ? array_shift( $selected_method_of_payment ) |
|
1237 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
1238 | + ? array_shift($selected_method_of_payment) |
|
1239 | 1239 | : $selected_method_of_payment; |
1240 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
1240 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
1241 | 1241 | // store it in the session so that it's available for all subsequent requests including AJAX |
1242 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
1242 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
1243 | 1243 | } else { |
1244 | 1244 | // or is is set in the session ? |
1245 | 1245 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | ); |
1248 | 1248 | } |
1249 | 1249 | // do ya really really gotta have it? |
1250 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
1250 | + if (empty($selected_method_of_payment) && $required) { |
|
1251 | 1251 | EE_Error::add_error( |
1252 | 1252 | sprintf( |
1253 | 1253 | __( |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | ), |
1257 | 1257 | '<br/>', |
1258 | 1258 | '<br/>', |
1259 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1259 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1260 | 1260 | ), |
1261 | 1261 | __FILE__, |
1262 | 1262 | __FUNCTION__, |
@@ -1283,13 +1283,13 @@ discard block |
||
1283 | 1283 | * @throws \EE_Error |
1284 | 1284 | */ |
1285 | 1285 | public function switch_payment_method() { |
1286 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1286 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1287 | 1287 | return false; |
1288 | 1288 | } |
1289 | - if ( apply_filters( |
|
1289 | + if (apply_filters( |
|
1290 | 1290 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1291 | 1291 | false |
1292 | - ) ) { |
|
1292 | + )) { |
|
1293 | 1293 | EE_Error::add_success( |
1294 | 1294 | apply_filters( |
1295 | 1295 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1304,13 +1304,13 @@ discard block |
||
1304 | 1304 | ); |
1305 | 1305 | } |
1306 | 1306 | // generate billing form for selected method of payment if it hasn't been done already |
1307 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1307 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1308 | 1308 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1309 | 1309 | $this->checkout->payment_method |
1310 | 1310 | ); |
1311 | 1311 | } |
1312 | 1312 | // fill form with attendee info if applicable |
1313 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1313 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1314 | 1314 | && $this->checkout->transaction_has_primary_registrant() |
1315 | 1315 | ) { |
1316 | 1316 | $this->checkout->billing_form->populate_from_attendee( |
@@ -1318,7 +1318,7 @@ discard block |
||
1318 | 1318 | ); |
1319 | 1319 | } |
1320 | 1320 | // and debug content |
1321 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1321 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1322 | 1322 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
1323 | 1323 | ) { |
1324 | 1324 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1326,15 +1326,15 @@ discard block |
||
1326 | 1326 | ); |
1327 | 1327 | } |
1328 | 1328 | // get html and validation rules for form |
1329 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
1329 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
1330 | 1330 | $this->checkout->json_response->set_return_data( |
1331 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
1331 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
1332 | 1332 | ); |
1333 | 1333 | // localize validation rules for main form |
1334 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
1335 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1334 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
1335 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1336 | 1336 | } else { |
1337 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
1337 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
1338 | 1338 | } |
1339 | 1339 | //prevents advancement to next step |
1340 | 1340 | $this->checkout->continue_reg = false; |
@@ -1351,12 +1351,12 @@ discard block |
||
1351 | 1351 | */ |
1352 | 1352 | protected function _verify_payment_method_is_set() { |
1353 | 1353 | // generate billing form for selected method of payment if it hasn't been done already |
1354 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1354 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1355 | 1355 | // how have they chosen to pay? |
1356 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1356 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1357 | 1357 | } |
1358 | 1358 | // verify payment method |
1359 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1359 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1360 | 1360 | // get payment method for selected method of payment |
1361 | 1361 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1362 | 1362 | } |
@@ -1375,25 +1375,25 @@ discard block |
||
1375 | 1375 | * @throws \EE_Error |
1376 | 1376 | */ |
1377 | 1377 | public function save_payer_details_via_ajax() { |
1378 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1378 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1379 | 1379 | return; |
1380 | 1380 | } |
1381 | 1381 | // generate billing form for selected method of payment if it hasn't been done already |
1382 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1382 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1383 | 1383 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1384 | 1384 | $this->checkout->payment_method |
1385 | 1385 | ); |
1386 | 1386 | } |
1387 | 1387 | // generate primary attendee from payer info if applicable |
1388 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1388 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1389 | 1389 | $attendee = $this->_create_attendee_from_request_data(); |
1390 | - if ( $attendee instanceof EE_Attendee ) { |
|
1391 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
1392 | - if ( $registration->is_primary_registrant() ) { |
|
1390 | + if ($attendee instanceof EE_Attendee) { |
|
1391 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
1392 | + if ($registration->is_primary_registrant()) { |
|
1393 | 1393 | $this->checkout->primary_attendee_obj = $attendee; |
1394 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1395 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1396 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1394 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1395 | + $registration->set_attendee_id($attendee->ID()); |
|
1396 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1397 | 1397 | } |
1398 | 1398 | } |
1399 | 1399 | } |
@@ -1411,50 +1411,50 @@ discard block |
||
1411 | 1411 | */ |
1412 | 1412 | protected function _create_attendee_from_request_data() { |
1413 | 1413 | // get State ID |
1414 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1415 | - if ( ! empty( $STA_ID ) ) { |
|
1414 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1415 | + if ( ! empty($STA_ID)) { |
|
1416 | 1416 | // can we get state object from name ? |
1417 | - EE_Registry::instance()->load_model( 'State' ); |
|
1418 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
1419 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1417 | + EE_Registry::instance()->load_model('State'); |
|
1418 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1419 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1420 | 1420 | } |
1421 | 1421 | // get Country ISO |
1422 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1423 | - if ( ! empty( $CNT_ISO ) ) { |
|
1422 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1423 | + if ( ! empty($CNT_ISO)) { |
|
1424 | 1424 | // can we get country object from name ? |
1425 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1425 | + EE_Registry::instance()->load_model('Country'); |
|
1426 | 1426 | $country = EEM_Country::instance()->get_col( |
1427 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
1427 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
1428 | 1428 | 'CNT_ISO' |
1429 | 1429 | ); |
1430 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1430 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1431 | 1431 | } |
1432 | 1432 | // grab attendee data |
1433 | 1433 | $attendee_data = array( |
1434 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1435 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1436 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1437 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1438 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1439 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1434 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1435 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1436 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1437 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1438 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1439 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1440 | 1440 | 'STA_ID' => $STA_ID, |
1441 | 1441 | 'CNT_ISO' => $CNT_ISO, |
1442 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1443 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1442 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1443 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1444 | 1444 | ); |
1445 | 1445 | // validate the email address since it is the most important piece of info |
1446 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
1446 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
1447 | 1447 | EE_Error::add_error( |
1448 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
1448 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
1449 | 1449 | __FILE__, |
1450 | 1450 | __FUNCTION__, |
1451 | 1451 | __LINE__ |
1452 | 1452 | ); |
1453 | 1453 | } |
1454 | 1454 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1455 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
1456 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1457 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1455 | + if ( ! empty($attendee_data['ATT_fname']) |
|
1456 | + && ! empty($attendee_data['ATT_lname']) |
|
1457 | + && ! empty($attendee_data['ATT_email']) |
|
1458 | 1458 | ) { |
1459 | 1459 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1460 | 1460 | array( |
@@ -1463,19 +1463,19 @@ discard block |
||
1463 | 1463 | 'ATT_email' => $attendee_data['ATT_email'] |
1464 | 1464 | ) |
1465 | 1465 | ); |
1466 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1466 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1467 | 1467 | return $existing_attendee; |
1468 | 1468 | } |
1469 | 1469 | } |
1470 | 1470 | // no existing attendee? kk let's create a new one |
1471 | 1471 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1472 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
1472 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
1473 | 1473 | ? $attendee_data['ATT_fname'] |
1474 | 1474 | : $attendee_data['ATT_email']; |
1475 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
1475 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
1476 | 1476 | ? $attendee_data['ATT_lname'] |
1477 | 1477 | : $attendee_data['ATT_email']; |
1478 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1478 | + return EE_Attendee::new_instance($attendee_data); |
|
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | |
@@ -1493,26 +1493,26 @@ discard block |
||
1493 | 1493 | // how have they chosen to pay? |
1494 | 1494 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
1495 | 1495 | ? 'no_payment_required' |
1496 | - : $this->_get_selected_method_of_payment( true ); |
|
1496 | + : $this->_get_selected_method_of_payment(true); |
|
1497 | 1497 | // choose your own adventure based on method_of_payment |
1498 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1498 | + switch ($this->checkout->selected_method_of_payment) { |
|
1499 | 1499 | |
1500 | 1500 | case 'events_sold_out' : |
1501 | 1501 | $this->checkout->redirect = true; |
1502 | 1502 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1503 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1503 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1504 | 1504 | // mark this reg step as completed |
1505 | 1505 | $this->set_completed(); |
1506 | 1506 | return false; |
1507 | 1507 | break; |
1508 | 1508 | |
1509 | 1509 | case 'payments_closed' : |
1510 | - if ( apply_filters( |
|
1510 | + if (apply_filters( |
|
1511 | 1511 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
1512 | 1512 | false |
1513 | - ) ) { |
|
1513 | + )) { |
|
1514 | 1514 | EE_Error::add_success( |
1515 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
1515 | + __('no payment required at this time.', 'event_espresso'), |
|
1516 | 1516 | __FILE__, |
1517 | 1517 | __FUNCTION__, |
1518 | 1518 | __LINE__ |
@@ -1524,12 +1524,12 @@ discard block |
||
1524 | 1524 | break; |
1525 | 1525 | |
1526 | 1526 | case 'no_payment_required' : |
1527 | - if ( apply_filters( |
|
1527 | + if (apply_filters( |
|
1528 | 1528 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
1529 | 1529 | false |
1530 | - ) ) { |
|
1530 | + )) { |
|
1531 | 1531 | EE_Error::add_success( |
1532 | - __( 'no payment required.', 'event_espresso' ), |
|
1532 | + __('no payment required.', 'event_espresso'), |
|
1533 | 1533 | __FILE__, |
1534 | 1534 | __FUNCTION__, |
1535 | 1535 | __LINE__ |
@@ -1549,15 +1549,15 @@ discard block |
||
1549 | 1549 | EE_Registry::instance()->SSN->checkout()->revisit |
1550 | 1550 | ); |
1551 | 1551 | // calculate difference between the two arrays |
1552 | - $registrations = array_diff( $registrations, $ejected_registrations ); |
|
1553 | - if ( empty( $registrations ) ) { |
|
1552 | + $registrations = array_diff($registrations, $ejected_registrations); |
|
1553 | + if (empty($registrations)) { |
|
1554 | 1554 | $this->_redirect_because_event_sold_out(); |
1555 | 1555 | return false; |
1556 | 1556 | } |
1557 | 1557 | $payment_successful = $this->_process_payment(); |
1558 | - if ( $payment_successful ) { |
|
1558 | + if ($payment_successful) { |
|
1559 | 1559 | $this->checkout->continue_reg = true; |
1560 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1560 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1561 | 1561 | } else { |
1562 | 1562 | $this->checkout->continue_reg = false; |
1563 | 1563 | } |
@@ -1578,10 +1578,10 @@ discard block |
||
1578 | 1578 | $this->checkout->continue_reg = false; |
1579 | 1579 | // set redirect URL |
1580 | 1580 | $this->checkout->redirect_url = add_query_arg( |
1581 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1581 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1582 | 1582 | $this->checkout->current_step->reg_step_url() |
1583 | 1583 | ); |
1584 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1584 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | |
@@ -1594,8 +1594,8 @@ discard block |
||
1594 | 1594 | * @return void |
1595 | 1595 | * @throws \EE_Error |
1596 | 1596 | */ |
1597 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1598 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1597 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1598 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1599 | 1599 | case EE_PMT_Base::offsite : |
1600 | 1600 | break; |
1601 | 1601 | case EE_PMT_Base::onsite : |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | public function update_reg_step() { |
1619 | 1619 | $success = true; |
1620 | 1620 | // if payment required |
1621 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1621 | + if ($this->checkout->transaction->total() > 0) { |
|
1622 | 1622 | do_action( |
1623 | 1623 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
1624 | 1624 | $this->checkout->transaction |
@@ -1626,13 +1626,13 @@ discard block |
||
1626 | 1626 | // attempt payment via payment method |
1627 | 1627 | $success = $this->process_reg_step(); |
1628 | 1628 | } |
1629 | - if ( $success && ! $this->checkout->redirect ) { |
|
1629 | + if ($success && ! $this->checkout->redirect) { |
|
1630 | 1630 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
1631 | 1631 | $this->checkout->transaction->ID() |
1632 | 1632 | ); |
1633 | 1633 | // set return URL |
1634 | 1634 | $this->checkout->redirect_url = add_query_arg( |
1635 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1635 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1636 | 1636 | $this->checkout->thank_you_page_url |
1637 | 1637 | ); |
1638 | 1638 | } |
@@ -1652,28 +1652,28 @@ discard block |
||
1652 | 1652 | // clear any previous errors related to not selecting a payment method |
1653 | 1653 | // EE_Error::overwrite_errors(); |
1654 | 1654 | // ya gotta make a choice man |
1655 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1655 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1656 | 1656 | $this->checkout->json_response->set_plz_select_method_of_payment( |
1657 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1657 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1658 | 1658 | ); |
1659 | 1659 | return false; |
1660 | 1660 | } |
1661 | 1661 | // get EE_Payment_Method object |
1662 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1662 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1663 | 1663 | return false; |
1664 | 1664 | } |
1665 | 1665 | // setup billing form |
1666 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1666 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1667 | 1667 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1668 | 1668 | $this->checkout->payment_method |
1669 | 1669 | ); |
1670 | 1670 | // bad billing form ? |
1671 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1671 | + if ( ! $this->_billing_form_is_valid()) { |
|
1672 | 1672 | return false; |
1673 | 1673 | } |
1674 | 1674 | } |
1675 | 1675 | // ensure primary registrant has been fully processed |
1676 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1676 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1677 | 1677 | return false; |
1678 | 1678 | } |
1679 | 1679 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1681,12 +1681,12 @@ discard block |
||
1681 | 1681 | // 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 |
1682 | 1682 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1683 | 1683 | // attempt payment |
1684 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1684 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1685 | 1685 | // process results |
1686 | - $payment = $this->_validate_payment( $payment ); |
|
1687 | - $payment = $this->_post_payment_processing( $payment ); |
|
1686 | + $payment = $this->_validate_payment($payment); |
|
1687 | + $payment = $this->_post_payment_processing($payment); |
|
1688 | 1688 | // verify payment |
1689 | - if ( $payment instanceof EE_Payment ) { |
|
1689 | + if ($payment instanceof EE_Payment) { |
|
1690 | 1690 | // store that for later |
1691 | 1691 | $this->checkout->payment = $payment; |
1692 | 1692 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
@@ -1700,7 +1700,7 @@ discard block |
||
1700 | 1700 | } else { |
1701 | 1701 | return false; |
1702 | 1702 | } |
1703 | - } else if ( $payment === true ) { |
|
1703 | + } else if ($payment === true) { |
|
1704 | 1704 | // please note that offline payment methods will NOT make a payment, |
1705 | 1705 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1706 | 1706 | $this->checkout->payment = $payment; |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | ); |
1726 | 1726 | $html = $payment_method_billing_info->get_html(); |
1727 | 1727 | $html .= $this->checkout->redirect_form; |
1728 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1728 | + EE_Registry::instance()->REQ->add_output($html); |
|
1729 | 1729 | return true; |
1730 | 1730 | } |
1731 | 1731 | |
@@ -1739,28 +1739,28 @@ discard block |
||
1739 | 1739 | * @throws \EE_Error |
1740 | 1740 | */ |
1741 | 1741 | private function _billing_form_is_valid() { |
1742 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1742 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1743 | 1743 | return true; |
1744 | 1744 | } |
1745 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1746 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1745 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1746 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1747 | 1747 | $this->checkout->billing_form->receive_form_submission(); |
1748 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1748 | + if ($this->checkout->billing_form->is_valid()) { |
|
1749 | 1749 | return true; |
1750 | 1750 | } |
1751 | 1751 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1752 | 1752 | $error_strings = array(); |
1753 | - foreach ( $validation_errors as $validation_error ) { |
|
1754 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1753 | + foreach ($validation_errors as $validation_error) { |
|
1754 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1755 | 1755 | $form_section = $validation_error->get_form_section(); |
1756 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
1756 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1757 | 1757 | $label = $form_section->html_label_text(); |
1758 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
1758 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1759 | 1759 | $label = $form_section->name(); |
1760 | 1760 | } else { |
1761 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1761 | + $label = __('Validation Error', 'event_espresso'); |
|
1762 | 1762 | } |
1763 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1763 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1764 | 1764 | } |
1765 | 1765 | } |
1766 | 1766 | EE_Error::add_error( |
@@ -1770,7 +1770,7 @@ discard block |
||
1770 | 1770 | 'event_espresso' |
1771 | 1771 | ), |
1772 | 1772 | '<br/>', |
1773 | - implode( '<br/>', $error_strings ) |
|
1773 | + implode('<br/>', $error_strings) |
|
1774 | 1774 | ), |
1775 | 1775 | __FILE__, |
1776 | 1776 | __FUNCTION__, |
@@ -1789,7 +1789,7 @@ discard block |
||
1789 | 1789 | } |
1790 | 1790 | } else { |
1791 | 1791 | EE_Error::add_error( |
1792 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
1792 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
1793 | 1793 | __FILE__, |
1794 | 1794 | __FUNCTION__, |
1795 | 1795 | __LINE__ |
@@ -1828,7 +1828,7 @@ discard block |
||
1828 | 1828 | // save the TXN ( which clears cached copy of primary_registration) |
1829 | 1829 | $this->checkout->transaction->save(); |
1830 | 1830 | // grab TXN ID and save it to the primary_registration |
1831 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1831 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1832 | 1832 | // save what we have so far |
1833 | 1833 | $primary_registration->save(); |
1834 | 1834 | return true; |
@@ -1846,7 +1846,7 @@ discard block |
||
1846 | 1846 | private function _capture_primary_registration_data_from_billing_form() { |
1847 | 1847 | // convert billing form data into an attendee |
1848 | 1848 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1849 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1849 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1850 | 1850 | EE_Error::add_error( |
1851 | 1851 | sprintf( |
1852 | 1852 | __( |
@@ -1854,7 +1854,7 @@ discard block |
||
1854 | 1854 | 'event_espresso' |
1855 | 1855 | ), |
1856 | 1856 | '<br/>', |
1857 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1857 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1858 | 1858 | ), |
1859 | 1859 | __FILE__, |
1860 | 1860 | __FUNCTION__, |
@@ -1863,7 +1863,7 @@ discard block |
||
1863 | 1863 | return false; |
1864 | 1864 | } |
1865 | 1865 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1866 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1866 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1867 | 1867 | EE_Error::add_error( |
1868 | 1868 | sprintf( |
1869 | 1869 | __( |
@@ -1871,7 +1871,7 @@ discard block |
||
1871 | 1871 | 'event_espresso' |
1872 | 1872 | ), |
1873 | 1873 | '<br/>', |
1874 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1874 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1875 | 1875 | ), |
1876 | 1876 | __FILE__, |
1877 | 1877 | __FUNCTION__, |
@@ -1879,7 +1879,7 @@ discard block |
||
1879 | 1879 | ); |
1880 | 1880 | return false; |
1881 | 1881 | } |
1882 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
1882 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
1883 | 1883 | instanceof |
1884 | 1884 | EE_Attendee |
1885 | 1885 | ) { |
@@ -1890,7 +1890,7 @@ discard block |
||
1890 | 1890 | 'event_espresso' |
1891 | 1891 | ), |
1892 | 1892 | '<br/>', |
1893 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1893 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1894 | 1894 | ), |
1895 | 1895 | __FILE__, |
1896 | 1896 | __FUNCTION__, |
@@ -1899,9 +1899,9 @@ discard block |
||
1899 | 1899 | return false; |
1900 | 1900 | } |
1901 | 1901 | /** @type EE_Registration_Processor $registration_processor */ |
1902 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1902 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1903 | 1903 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1904 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1904 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1905 | 1905 | return true; |
1906 | 1906 | } |
1907 | 1907 | |
@@ -1916,22 +1916,22 @@ discard block |
||
1916 | 1916 | * @throws \EE_Error |
1917 | 1917 | */ |
1918 | 1918 | private function _get_payment_method_for_selected_method_of_payment() { |
1919 | - if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) { |
|
1919 | + if ($this->checkout->selected_method_of_payment === 'events_sold_out') { |
|
1920 | 1920 | $this->_redirect_because_event_sold_out(); |
1921 | 1921 | return null; |
1922 | 1922 | } |
1923 | 1923 | // get EE_Payment_Method object |
1924 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
1925 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1924 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1925 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1926 | 1926 | } else { |
1927 | 1927 | // load EEM_Payment_Method |
1928 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1928 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1929 | 1929 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1930 | 1930 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1931 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1931 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1932 | 1932 | } |
1933 | 1933 | // verify $payment_method |
1934 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1934 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1935 | 1935 | // not a payment |
1936 | 1936 | EE_Error::add_error( |
1937 | 1937 | sprintf( |
@@ -1940,7 +1940,7 @@ discard block |
||
1940 | 1940 | 'event_espresso' |
1941 | 1941 | ), |
1942 | 1942 | '<br/>', |
1943 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1943 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1944 | 1944 | ), |
1945 | 1945 | __FILE__, |
1946 | 1946 | __FUNCTION__, |
@@ -1949,7 +1949,7 @@ discard block |
||
1949 | 1949 | return null; |
1950 | 1950 | } |
1951 | 1951 | // and verify it has a valid Payment_Method Type object |
1952 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1952 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1953 | 1953 | // not a payment |
1954 | 1954 | EE_Error::add_error( |
1955 | 1955 | sprintf( |
@@ -1958,7 +1958,7 @@ discard block |
||
1958 | 1958 | 'event_espresso' |
1959 | 1959 | ), |
1960 | 1960 | '<br/>', |
1961 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1961 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1962 | 1962 | ), |
1963 | 1963 | __FILE__, |
1964 | 1964 | __FUNCTION__, |
@@ -1979,29 +1979,29 @@ discard block |
||
1979 | 1979 | * @return mixed EE_Payment | boolean |
1980 | 1980 | * @throws \EE_Error |
1981 | 1981 | */ |
1982 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1982 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1983 | 1983 | $payment = null; |
1984 | 1984 | $this->checkout->transaction->save(); |
1985 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1986 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1985 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1986 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1987 | 1987 | return false; |
1988 | 1988 | } |
1989 | 1989 | try { |
1990 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1990 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1991 | 1991 | // generate payment object |
1992 | 1992 | $payment = $payment_processor->process_payment( |
1993 | 1993 | $payment_method, |
1994 | 1994 | $this->checkout->transaction, |
1995 | 1995 | $this->checkout->amount_owing, |
1996 | 1996 | $this->checkout->billing_form, |
1997 | - $this->_get_return_url( $payment_method ), |
|
1997 | + $this->_get_return_url($payment_method), |
|
1998 | 1998 | 'CART', |
1999 | 1999 | $this->checkout->admin_request, |
2000 | 2000 | true, |
2001 | 2001 | $this->reg_step_url() |
2002 | 2002 | ); |
2003 | - } catch ( Exception $e ) { |
|
2004 | - $this->_handle_payment_processor_exception( $e ); |
|
2003 | + } catch (Exception $e) { |
|
2004 | + $this->_handle_payment_processor_exception($e); |
|
2005 | 2005 | } |
2006 | 2006 | return $payment; |
2007 | 2007 | } |
@@ -2016,7 +2016,7 @@ discard block |
||
2016 | 2016 | * @return void |
2017 | 2017 | * @throws \EE_Error |
2018 | 2018 | */ |
2019 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
2019 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
2020 | 2020 | EE_Error::add_error( |
2021 | 2021 | sprintf( |
2022 | 2022 | __( |
@@ -2024,7 +2024,7 @@ discard block |
||
2024 | 2024 | 'event_espresso' |
2025 | 2025 | ), |
2026 | 2026 | '<br/>', |
2027 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
2027 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
2028 | 2028 | $e->getMessage(), |
2029 | 2029 | $e->getFile(), |
2030 | 2030 | $e->getLine() |
@@ -2045,9 +2045,9 @@ discard block |
||
2045 | 2045 | * @return string |
2046 | 2046 | * @throws \EE_Error |
2047 | 2047 | */ |
2048 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
2048 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
2049 | 2049 | $return_url = ''; |
2050 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
2050 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
2051 | 2051 | case EE_PMT_Base::offsite : |
2052 | 2052 | $return_url = add_query_arg( |
2053 | 2053 | array( |
@@ -2076,12 +2076,12 @@ discard block |
||
2076 | 2076 | * @return EE_Payment | FALSE |
2077 | 2077 | * @throws \EE_Error |
2078 | 2078 | */ |
2079 | - private function _validate_payment( $payment = null ) { |
|
2080 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
2079 | + private function _validate_payment($payment = null) { |
|
2080 | + if ($this->checkout->payment_method->is_off_line()) { |
|
2081 | 2081 | return true; |
2082 | 2082 | } |
2083 | 2083 | // verify payment object |
2084 | - if ( ! $payment instanceof EE_Payment ) { |
|
2084 | + if ( ! $payment instanceof EE_Payment) { |
|
2085 | 2085 | // not a payment |
2086 | 2086 | EE_Error::add_error( |
2087 | 2087 | sprintf( |
@@ -2090,7 +2090,7 @@ discard block |
||
2090 | 2090 | 'event_espresso' |
2091 | 2091 | ), |
2092 | 2092 | '<br/>', |
2093 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2093 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2094 | 2094 | ), |
2095 | 2095 | __FILE__, |
2096 | 2096 | __FUNCTION__, |
@@ -2111,27 +2111,27 @@ discard block |
||
2111 | 2111 | * @return bool |
2112 | 2112 | * @throws \EE_Error |
2113 | 2113 | */ |
2114 | - private function _post_payment_processing( $payment = null ) { |
|
2114 | + private function _post_payment_processing($payment = null) { |
|
2115 | 2115 | // Off-Line payment? |
2116 | - if ( $payment === true ) { |
|
2116 | + if ($payment === true) { |
|
2117 | 2117 | //$this->_setup_redirect_for_next_step(); |
2118 | 2118 | return true; |
2119 | 2119 | // On-Site payment? |
2120 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
2121 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
2120 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
2121 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
2122 | 2122 | //$this->_setup_redirect_for_next_step(); |
2123 | 2123 | $this->checkout->continue_reg = false; |
2124 | 2124 | } |
2125 | 2125 | // Off-Site payment? |
2126 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
2126 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
2127 | 2127 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
2128 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
2129 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
2128 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
2129 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
2130 | 2130 | $this->checkout->redirect = true; |
2131 | 2131 | $this->checkout->redirect_form = $payment->redirect_form(); |
2132 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
2132 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
2133 | 2133 | // set JSON response |
2134 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
2134 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
2135 | 2135 | // set cron job for finalizing the TXN |
2136 | 2136 | // in case the user does not return from the off-site gateway |
2137 | 2137 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -2139,7 +2139,7 @@ discard block |
||
2139 | 2139 | $this->checkout->transaction->ID() |
2140 | 2140 | ); |
2141 | 2141 | // and lastly, let's bump the payment status to pending |
2142 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
2142 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
2143 | 2143 | $payment->save(); |
2144 | 2144 | } else { |
2145 | 2145 | // not a payment |
@@ -2151,7 +2151,7 @@ discard block |
||
2151 | 2151 | 'event_espresso' |
2152 | 2152 | ), |
2153 | 2153 | '<br/>', |
2154 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2154 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2155 | 2155 | ), |
2156 | 2156 | __FILE__, |
2157 | 2157 | __FUNCTION__, |
@@ -2189,21 +2189,21 @@ discard block |
||
2189 | 2189 | * @return bool |
2190 | 2190 | * @throws \EE_Error |
2191 | 2191 | */ |
2192 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
2192 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
2193 | 2193 | // off-line payment? carry on |
2194 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
2194 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
2195 | 2195 | return true; |
2196 | 2196 | } |
2197 | 2197 | // verify payment validity |
2198 | - if ( $payment instanceof EE_Payment ) { |
|
2199 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
2198 | + if ($payment instanceof EE_Payment) { |
|
2199 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
2200 | 2200 | $msg = $payment->gateway_response(); |
2201 | 2201 | // check results |
2202 | - switch ( $payment->status() ) { |
|
2202 | + switch ($payment->status()) { |
|
2203 | 2203 | // good payment |
2204 | 2204 | case EEM_Payment::status_id_approved : |
2205 | 2205 | EE_Error::add_success( |
2206 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
2206 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
2207 | 2207 | __FILE__, |
2208 | 2208 | __FUNCTION__, |
2209 | 2209 | __LINE__ |
@@ -2212,45 +2212,45 @@ discard block |
||
2212 | 2212 | break; |
2213 | 2213 | // slow payment |
2214 | 2214 | case EEM_Payment::status_id_pending : |
2215 | - if ( empty( $msg ) ) { |
|
2215 | + if (empty($msg)) { |
|
2216 | 2216 | $msg = __( |
2217 | 2217 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
2218 | 2218 | 'event_espresso' |
2219 | 2219 | ); |
2220 | 2220 | } |
2221 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2221 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2222 | 2222 | return true; |
2223 | 2223 | break; |
2224 | 2224 | // don't wanna payment |
2225 | 2225 | case EEM_Payment::status_id_cancelled : |
2226 | - if ( empty( $msg ) ) { |
|
2226 | + if (empty($msg)) { |
|
2227 | 2227 | $msg = _n( |
2228 | 2228 | 'Payment cancelled. Please try again.', |
2229 | 2229 | 'Payment cancelled. Please try again or select another method of payment.', |
2230 | - count( $this->checkout->available_payment_methods ), |
|
2230 | + count($this->checkout->available_payment_methods), |
|
2231 | 2231 | 'event_espresso' |
2232 | 2232 | ); |
2233 | 2233 | } |
2234 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2234 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2235 | 2235 | return false; |
2236 | 2236 | break; |
2237 | 2237 | // not enough payment |
2238 | 2238 | case EEM_Payment::status_id_declined : |
2239 | - if ( empty( $msg ) ) { |
|
2239 | + if (empty($msg)) { |
|
2240 | 2240 | $msg = _n( |
2241 | 2241 | 'We\'re sorry but your payment was declined. Please try again.', |
2242 | 2242 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
2243 | - count( $this->checkout->available_payment_methods ), |
|
2243 | + count($this->checkout->available_payment_methods), |
|
2244 | 2244 | 'event_espresso' |
2245 | 2245 | ); |
2246 | 2246 | } |
2247 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2247 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2248 | 2248 | return false; |
2249 | 2249 | break; |
2250 | 2250 | // bad payment |
2251 | 2251 | case EEM_Payment::status_id_failed : |
2252 | - if ( ! empty( $msg ) ) { |
|
2253 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2252 | + if ( ! empty($msg)) { |
|
2253 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2254 | 2254 | return false; |
2255 | 2255 | } |
2256 | 2256 | // default to error below |
@@ -2259,7 +2259,7 @@ discard block |
||
2259 | 2259 | } |
2260 | 2260 | // off-site payment gateway responses are too unreliable, so let's just assume that |
2261 | 2261 | // the payment processing is just running slower than the registrant's request |
2262 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
2262 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
2263 | 2263 | return true; |
2264 | 2264 | } |
2265 | 2265 | EE_Error::add_error( |
@@ -2269,7 +2269,7 @@ discard block |
||
2269 | 2269 | 'event_espresso' |
2270 | 2270 | ), |
2271 | 2271 | '<br/>', |
2272 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2272 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2273 | 2273 | ), |
2274 | 2274 | __FILE__, |
2275 | 2275 | __FUNCTION__, |
@@ -2302,13 +2302,13 @@ discard block |
||
2302 | 2302 | public function process_gateway_response() { |
2303 | 2303 | $payment = null; |
2304 | 2304 | // how have they chosen to pay? |
2305 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
2305 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
2306 | 2306 | // get EE_Payment_Method object |
2307 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
2307 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
2308 | 2308 | $this->checkout->continue_reg = false; |
2309 | 2309 | return false; |
2310 | 2310 | } |
2311 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
2311 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
2312 | 2312 | return false; |
2313 | 2313 | } |
2314 | 2314 | $this->_validate_offsite_return(); |
@@ -2322,23 +2322,23 @@ discard block |
||
2322 | 2322 | // true |
2323 | 2323 | //); |
2324 | 2324 | // verify TXN |
2325 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
2325 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
2326 | 2326 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
2327 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
2327 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
2328 | 2328 | $this->checkout->continue_reg = false; |
2329 | 2329 | return false; |
2330 | 2330 | } |
2331 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
2332 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
2333 | - $payment = $this->_validate_payment( $payment ); |
|
2331 | + $payment = $this->_process_off_site_payment($gateway); |
|
2332 | + $payment = $this->_process_cancelled_payments($payment); |
|
2333 | + $payment = $this->_validate_payment($payment); |
|
2334 | 2334 | // if payment was not declined by the payment gateway or cancelled by the registrant |
2335 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
2335 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
2336 | 2336 | //$this->_setup_redirect_for_next_step(); |
2337 | 2337 | // store that for later |
2338 | 2338 | $this->checkout->payment = $payment; |
2339 | 2339 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
2340 | 2340 | // because we will complete this step during the IPN processing then |
2341 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
2341 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
2342 | 2342 | $this->set_completed(); |
2343 | 2343 | } |
2344 | 2344 | return true; |
@@ -2362,21 +2362,21 @@ discard block |
||
2362 | 2362 | * @throws \EE_Error |
2363 | 2363 | */ |
2364 | 2364 | private function _validate_offsite_return() { |
2365 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
2366 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
2365 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
2366 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
2367 | 2367 | // Houston... we might have a problem |
2368 | 2368 | $invalid_TXN = false; |
2369 | 2369 | // first gather some info |
2370 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
2370 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2371 | 2371 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
2372 | 2372 | ? $valid_TXN->primary_registration() |
2373 | 2373 | : null; |
2374 | 2374 | // let's start by retrieving the cart for this TXN |
2375 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
2376 | - if ( $cart instanceof EE_Cart ) { |
|
2375 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
2376 | + if ($cart instanceof EE_Cart) { |
|
2377 | 2377 | // verify that the current cart has tickets |
2378 | 2378 | $tickets = $cart->get_tickets(); |
2379 | - if ( empty( $tickets ) ) { |
|
2379 | + if (empty($tickets)) { |
|
2380 | 2380 | $invalid_TXN = true; |
2381 | 2381 | } |
2382 | 2382 | } else { |
@@ -2386,35 +2386,35 @@ discard block |
||
2386 | 2386 | ? $primary_registrant->session_ID() |
2387 | 2387 | : null; |
2388 | 2388 | // validate current Session ID and compare against valid TXN session ID |
2389 | - if ( EE_Session::instance()->id() === null ) { |
|
2389 | + if (EE_Session::instance()->id() === null) { |
|
2390 | 2390 | $invalid_TXN = true; |
2391 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
2391 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
2392 | 2392 | // WARNING !!! |
2393 | 2393 | // this could be PayPal sending back duplicate requests (ya they do that) |
2394 | 2394 | // or it **could** mean someone is simply registering AGAIN after having just done so |
2395 | 2395 | // so now we need to determine if this current TXN looks valid or not |
2396 | 2396 | // has this step even been started ? |
2397 | - if ( $this->checkout->transaction->reg_step_completed( $this->slug() === false ) |
|
2397 | + if ($this->checkout->transaction->reg_step_completed($this->slug() === false) |
|
2398 | 2398 | ) { |
2399 | 2399 | // really? you're half way through this reg step, but you never started it ? |
2400 | 2400 | $invalid_TXN = true; |
2401 | 2401 | } |
2402 | 2402 | } |
2403 | - if ( $invalid_TXN ) { |
|
2403 | + if ($invalid_TXN) { |
|
2404 | 2404 | // is the valid TXN completed ? |
2405 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
2405 | + if ($valid_TXN instanceof EE_Transaction) { |
|
2406 | 2406 | // has this step even been started ? |
2407 | - $reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() ); |
|
2408 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
2407 | + $reg_step_completed = $valid_TXN->reg_step_completed($this->slug()); |
|
2408 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
2409 | 2409 | // so it **looks** like this is a double request from PayPal |
2410 | 2410 | // so let's try to pick up where we left off |
2411 | 2411 | $this->checkout->transaction = $valid_TXN; |
2412 | - $this->checkout->refresh_all_entities( true ); |
|
2412 | + $this->checkout->refresh_all_entities(true); |
|
2413 | 2413 | return; |
2414 | 2414 | } |
2415 | 2415 | } |
2416 | 2416 | // you appear to be lost? |
2417 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
2417 | + $this->_redirect_wayward_request($primary_registrant); |
|
2418 | 2418 | } |
2419 | 2419 | } |
2420 | 2420 | } |
@@ -2429,14 +2429,14 @@ discard block |
||
2429 | 2429 | * @return bool |
2430 | 2430 | * @throws \EE_Error |
2431 | 2431 | */ |
2432 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
2433 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2432 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
2433 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2434 | 2434 | // try redirecting based on the current TXN |
2435 | 2435 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
2436 | 2436 | ? $this->checkout->transaction->primary_registration() |
2437 | 2437 | : null; |
2438 | 2438 | } |
2439 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2439 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2440 | 2440 | EE_Error::add_error( |
2441 | 2441 | sprintf( |
2442 | 2442 | __( |
@@ -2444,7 +2444,7 @@ discard block |
||
2444 | 2444 | 'event_espresso' |
2445 | 2445 | ), |
2446 | 2446 | '<br/>', |
2447 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2447 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2448 | 2448 | ), |
2449 | 2449 | __FILE__, |
2450 | 2450 | __FUNCTION__, |
@@ -2475,17 +2475,17 @@ discard block |
||
2475 | 2475 | * @return \EE_Payment |
2476 | 2476 | * @throws \EE_Error |
2477 | 2477 | */ |
2478 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
2478 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
2479 | 2479 | try { |
2480 | 2480 | $request_data = \EE_Registry::instance()->REQ->params(); |
2481 | 2481 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
2482 | 2482 | $this->set_handle_IPN_in_this_request( |
2483 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
2483 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
2484 | 2484 | ); |
2485 | - if ( $this->handle_IPN_in_this_request() ) { |
|
2485 | + if ($this->handle_IPN_in_this_request()) { |
|
2486 | 2486 | // get payment details and process results |
2487 | 2487 | /** @type EE_Payment_Processor $payment_processor */ |
2488 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2488 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2489 | 2489 | $payment = $payment_processor->process_ipn( |
2490 | 2490 | $request_data, |
2491 | 2491 | $this->checkout->transaction, |
@@ -2498,14 +2498,14 @@ discard block |
||
2498 | 2498 | $payment = $this->checkout->transaction->last_payment(); |
2499 | 2499 | //$payment_source = 'last_payment'; |
2500 | 2500 | } |
2501 | - } catch ( Exception $e ) { |
|
2501 | + } catch (Exception $e) { |
|
2502 | 2502 | // let's just eat the exception and try to move on using any previously set payment info |
2503 | 2503 | $payment = $this->checkout->transaction->last_payment(); |
2504 | 2504 | //$payment_source = 'last_payment after Exception'; |
2505 | 2505 | // but if we STILL don't have a payment object |
2506 | - if ( ! $payment instanceof EE_Payment ) { |
|
2506 | + if ( ! $payment instanceof EE_Payment) { |
|
2507 | 2507 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
2508 | - $this->_handle_payment_processor_exception( $e ); |
|
2508 | + $this->_handle_payment_processor_exception($e); |
|
2509 | 2509 | } |
2510 | 2510 | } |
2511 | 2511 | // DEBUG LOG |
@@ -2530,13 +2530,13 @@ discard block |
||
2530 | 2530 | * @return EE_Payment | FALSE |
2531 | 2531 | * @throws \EE_Error |
2532 | 2532 | */ |
2533 | - private function _process_cancelled_payments( $payment = null ) { |
|
2533 | + private function _process_cancelled_payments($payment = null) { |
|
2534 | 2534 | if ( |
2535 | 2535 | $payment instanceof EE_Payment |
2536 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
2536 | + && isset($_REQUEST['ee_cancel_payment']) |
|
2537 | 2537 | && $payment->status() === EEM_Payment::status_id_failed |
2538 | 2538 | ) { |
2539 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2539 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2540 | 2540 | } |
2541 | 2541 | return $payment; |
2542 | 2542 | } |
@@ -2553,14 +2553,14 @@ discard block |
||
2553 | 2553 | public function get_transaction_details_for_gateways() { |
2554 | 2554 | $txn_details = array(); |
2555 | 2555 | // ya gotta make a choice man |
2556 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2556 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2557 | 2557 | $txn_details = array( |
2558 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2558 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2559 | 2559 | ); |
2560 | 2560 | } |
2561 | 2561 | // get EE_Payment_Method object |
2562 | 2562 | if ( |
2563 | - empty( $txn_details ) |
|
2563 | + empty($txn_details) |
|
2564 | 2564 | && |
2565 | 2565 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2566 | 2566 | ) { |
@@ -2572,8 +2572,8 @@ discard block |
||
2572 | 2572 | ) |
2573 | 2573 | ); |
2574 | 2574 | } |
2575 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2576 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2575 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2576 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2577 | 2577 | $txn_details = array( |
2578 | 2578 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2579 | 2579 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2584,7 +2584,7 @@ discard block |
||
2584 | 2584 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2585 | 2585 | 'payment_amount' => $this->checkout->amount_owing, |
2586 | 2586 | 'return_url' => $return_url, |
2587 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2587 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2588 | 2588 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2589 | 2589 | array( |
2590 | 2590 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2593,7 +2593,7 @@ discard block |
||
2593 | 2593 | ) |
2594 | 2594 | ); |
2595 | 2595 | } |
2596 | - echo json_encode( $txn_details ); |
|
2596 | + echo json_encode($txn_details); |
|
2597 | 2597 | exit(); |
2598 | 2598 | } |
2599 | 2599 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * CPT_Strategy |
4 | 4 | * |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function instance() { |
71 | 71 | // check if class object is instantiated |
72 | - if ( ! self::$_instance instanceof EE_CPT_Strategy ) { |
|
72 | + if ( ! self::$_instance instanceof EE_CPT_Strategy) { |
|
73 | 73 | self::$_instance = new self(); |
74 | 74 | } |
75 | 75 | return self::$_instance; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $this->_CPTs = EE_Register_CPTs::get_CPTs(); |
87 | 87 | $this->_CPT_endpoints = $this->_set_CPT_endpoints(); |
88 | 88 | $this->_CPT_taxonomies = EE_Register_CPTs::get_taxonomies(); |
89 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 5 ); |
|
89 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 5); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | */ |
121 | 121 | private function _set_CPT_endpoints() { |
122 | 122 | $_CPT_endpoints = array(); |
123 | - if ( is_array( $this->_CPTs )) { |
|
124 | - foreach ( $this->_CPTs as $CPT_type => $CPT ) { |
|
125 | - $_CPT_endpoints [ $CPT['plural_slug'] ] = $CPT_type; |
|
123 | + if (is_array($this->_CPTs)) { |
|
124 | + foreach ($this->_CPTs as $CPT_type => $CPT) { |
|
125 | + $_CPT_endpoints [$CPT['plural_slug']] = $CPT_type; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | return $_CPT_endpoints; |
@@ -140,21 +140,21 @@ discard block |
||
140 | 140 | * @param WP_Query $WP_Query |
141 | 141 | * @return void |
142 | 142 | */ |
143 | - public function pre_get_posts( $WP_Query ) { |
|
143 | + public function pre_get_posts($WP_Query) { |
|
144 | 144 | // check that post-type is set |
145 | - if ( ! $WP_Query instanceof WP_Query ) { |
|
145 | + if ( ! $WP_Query instanceof WP_Query) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | // add our conditionals |
149 | - $this->_set_EE_tags_on_WP_Query( $WP_Query ); |
|
149 | + $this->_set_EE_tags_on_WP_Query($WP_Query); |
|
150 | 150 | // check for terms |
151 | - $this->_set_post_type_for_terms( $WP_Query ); |
|
151 | + $this->_set_post_type_for_terms($WP_Query); |
|
152 | 152 | // make sure paging is always set |
153 | - $this->_set_paging( $WP_Query ); |
|
153 | + $this->_set_paging($WP_Query); |
|
154 | 154 | // is a taxonomy set ? |
155 | - $this->_set_CPT_taxonomies_on_WP_Query( $WP_Query ); |
|
155 | + $this->_set_CPT_taxonomies_on_WP_Query($WP_Query); |
|
156 | 156 | // loop thru post_types if set |
157 | - $this->_process_WP_Query_post_types( $WP_Query ); |
|
157 | + $this->_process_WP_Query_post_types($WP_Query); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param WP_Query $WP_Query |
166 | 166 | * @return void |
167 | 167 | */ |
168 | - private function _set_EE_tags_on_WP_Query( WP_Query $WP_Query) { |
|
168 | + private function _set_EE_tags_on_WP_Query(WP_Query $WP_Query) { |
|
169 | 169 | $WP_Query->is_espresso_event_single = FALSE; |
170 | 170 | $WP_Query->is_espresso_event_archive = FALSE; |
171 | 171 | $WP_Query->is_espresso_event_taxonomy = FALSE; |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @return void |
184 | 184 | */ |
185 | 185 | private function _set_CPT_terms() { |
186 | - if ( empty( $this->_CPT_terms )) { |
|
186 | + if (empty($this->_CPT_terms)) { |
|
187 | 187 | $terms = EEM_Term::instance()->get_all_CPT_post_tags(); |
188 | - foreach ( $terms as $term ) { |
|
189 | - if ( $term instanceof EE_Term ) { |
|
190 | - $this->_CPT_terms[ $term->slug() ] = $term; |
|
188 | + foreach ($terms as $term) { |
|
189 | + if ($term instanceof EE_Term) { |
|
190 | + $this->_CPT_terms[$term->slug()] = $term; |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | } |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | * @param $WP_Query |
203 | 203 | * @return void |
204 | 204 | */ |
205 | - private function _set_post_type_for_terms( WP_Query $WP_Query ) { |
|
205 | + private function _set_post_type_for_terms(WP_Query $WP_Query) { |
|
206 | 206 | // is a tag set ? |
207 | - if ( isset( $WP_Query->query['tag'] )) { |
|
207 | + if (isset($WP_Query->query['tag'])) { |
|
208 | 208 | // set post_tags |
209 | 209 | $this->_set_CPT_terms(); |
210 | 210 | // is this tag archive term in the list of terms used by our CPTs ? |
211 | - $term = isset ( $this->_CPT_terms[ $WP_Query->query['tag'] ] ) ? $this->_CPT_terms[ $WP_Query->query['tag'] ] : NULL; |
|
211 | + $term = isset ($this->_CPT_terms[$WP_Query->query['tag']]) ? $this->_CPT_terms[$WP_Query->query['tag']] : NULL; |
|
212 | 212 | // verify the term |
213 | - if ( $term instanceof EE_Term ) { |
|
214 | - $term->post_type = array_merge( array( 'post', 'page' ), (array)$term->post_type ); |
|
215 | - $term->post_type = apply_filters( 'FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term ); |
|
213 | + if ($term instanceof EE_Term) { |
|
214 | + $term->post_type = array_merge(array('post', 'page'), (array) $term->post_type); |
|
215 | + $term->post_type = apply_filters('FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term); |
|
216 | 216 | // if a post type is already set |
217 | - if ( isset( $WP_Query->query_vars['post_type'] )) { |
|
217 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
218 | 218 | // add to existing array |
219 | - $term->post_type = array_merge ( (array)$WP_Query->query_vars['post_type'], $term->post_type ); |
|
219 | + $term->post_type = array_merge((array) $WP_Query->query_vars['post_type'], $term->post_type); |
|
220 | 220 | } |
221 | 221 | // just set post_type to our CPT |
222 | - $WP_Query->set( 'post_type', array_unique( $term->post_type ) ); |
|
222 | + $WP_Query->set('post_type', array_unique($term->post_type)); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | } |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | * @param WP_Query $WP_Query |
234 | 234 | * @return void |
235 | 235 | */ |
236 | - public function _set_paging( $WP_Query ) { |
|
237 | - if ( $WP_Query->is_main_query() && apply_filters( 'FHEE__EE_CPT_Strategy___set_paging', TRUE )) { |
|
236 | + public function _set_paging($WP_Query) { |
|
237 | + if ($WP_Query->is_main_query() && apply_filters('FHEE__EE_CPT_Strategy___set_paging', TRUE)) { |
|
238 | 238 | $page = get_query_var('page') ? get_query_var('page') : NULL; |
239 | 239 | $paged = get_query_var('paged') ? get_query_var('paged') : $page; |
240 | - $WP_Query->set( 'paged', $paged ); |
|
240 | + $WP_Query->set('paged', $paged); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
@@ -247,28 +247,28 @@ discard block |
||
247 | 247 | * @access protected |
248 | 248 | * @param \WP_Query $WP_Query |
249 | 249 | */ |
250 | - protected function _set_CPT_taxonomies_on_WP_Query( WP_Query $WP_Query ) { |
|
250 | + protected function _set_CPT_taxonomies_on_WP_Query(WP_Query $WP_Query) { |
|
251 | 251 | // is a taxonomy set ? |
252 | - if ( $WP_Query->is_tax ) { |
|
252 | + if ($WP_Query->is_tax) { |
|
253 | 253 | // loop thru our taxonomies |
254 | - foreach ( $this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details ) { |
|
254 | + foreach ($this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details) { |
|
255 | 255 | // check if one of our taxonomies is set as a query var |
256 | - if ( isset( $WP_Query->query[ $CPT_taxonomy ] ) ) { |
|
256 | + if (isset($WP_Query->query[$CPT_taxonomy])) { |
|
257 | 257 | // but which CPT does that correspond to??? hmmm... guess we gotta go looping |
258 | - foreach ( $this->_CPTs as $post_type => $CPT ) { |
|
258 | + foreach ($this->_CPTs as $post_type => $CPT) { |
|
259 | 259 | // verify our CPT has args, is public and has taxonomies set |
260 | 260 | if ( |
261 | - isset( $CPT['args'], $CPT['args']['public'] ) |
|
261 | + isset($CPT['args'], $CPT['args']['public']) |
|
262 | 262 | && $CPT['args']['public'] |
263 | - && ! empty( $CPT['args']['taxonomies'] ) |
|
264 | - && in_array( $CPT_taxonomy, $CPT['args']['taxonomies'] ) |
|
263 | + && ! empty($CPT['args']['taxonomies']) |
|
264 | + && in_array($CPT_taxonomy, $CPT['args']['taxonomies']) |
|
265 | 265 | ) { |
266 | 266 | // if so, then add this CPT post_type to the current query's array of post_types' |
267 | - $WP_Query->query_vars['post_type'] = isset( $WP_Query->query_vars['post_type'] ) |
|
267 | + $WP_Query->query_vars['post_type'] = isset($WP_Query->query_vars['post_type']) |
|
268 | 268 | ? (array) $WP_Query->query_vars['post_type'] |
269 | 269 | : array(); |
270 | 270 | $WP_Query->query_vars['post_type'][] = $post_type; |
271 | - switch ( $post_type ) { |
|
271 | + switch ($post_type) { |
|
272 | 272 | case 'espresso_events' : |
273 | 273 | $WP_Query->is_espresso_event_taxonomy = true; |
274 | 274 | break; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | break; |
278 | 278 | default : |
279 | 279 | do_action( |
280 | - 'AHEE__EE_CPT_Strategy___set_CPT_taxonomies_on_WP_Query__for_' . $post_type . '_post_type', |
|
280 | + 'AHEE__EE_CPT_Strategy___set_CPT_taxonomies_on_WP_Query__for_'.$post_type.'_post_type', |
|
281 | 281 | $WP_Query, |
282 | 282 | $this |
283 | 283 | ); |
@@ -295,24 +295,24 @@ discard block |
||
295 | 295 | * @access public |
296 | 296 | * @param \WP_Query $WP_Query |
297 | 297 | */ |
298 | - protected function _process_WP_Query_post_types( WP_Query $WP_Query ) { |
|
299 | - if ( isset( $WP_Query->query_vars['post_type'] ) ) { |
|
298 | + protected function _process_WP_Query_post_types(WP_Query $WP_Query) { |
|
299 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
300 | 300 | // loop thru post_types as array |
301 | - foreach ( (array) $WP_Query->query_vars['post_type'] as $post_type ) { |
|
301 | + foreach ((array) $WP_Query->query_vars['post_type'] as $post_type) { |
|
302 | 302 | // is current query for an EE CPT ? |
303 | - if ( isset( $this->_CPTs[ $post_type ] ) ) { |
|
303 | + if (isset($this->_CPTs[$post_type])) { |
|
304 | 304 | // is EE on or off ? |
305 | - if ( EE_Maintenance_Mode::instance()->level() ) { |
|
305 | + if (EE_Maintenance_Mode::instance()->level()) { |
|
306 | 306 | // reroute CPT template view to maintenance_mode.template.php |
307 | - if ( ! has_filter( 'template_include', array( 'EE_Maintenance_Mode', 'template_include' ) ) ) { |
|
308 | - add_filter( 'template_include', array( 'EE_Maintenance_Mode', 'template_include' ), 99999 ); |
|
307 | + if ( ! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) { |
|
308 | + add_filter('template_include', array('EE_Maintenance_Mode', 'template_include'), 99999); |
|
309 | 309 | } |
310 | - if ( has_filter( 'the_content', array( EE_Maintenance_Mode::instance(), 'the_content' ) ) ) { |
|
311 | - add_filter( 'the_content', array( $this, 'inject_EE_shortcode_placeholder' ), 1 ); |
|
310 | + if (has_filter('the_content', array(EE_Maintenance_Mode::instance(), 'the_content'))) { |
|
311 | + add_filter('the_content', array($this, 'inject_EE_shortcode_placeholder'), 1); |
|
312 | 312 | } |
313 | 313 | return; |
314 | 314 | } |
315 | - $this->_generate_CptQueryModifier( $WP_Query, $post_type ); |
|
315 | + $this->_generate_CptQueryModifier($WP_Query, $post_type); |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | } |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | * @param \WP_Query $WP_Query |
325 | 325 | * @param string $post_type |
326 | 326 | */ |
327 | - protected function _generate_CptQueryModifier( WP_Query $WP_Query, $post_type ) { |
|
327 | + protected function _generate_CptQueryModifier(WP_Query $WP_Query, $post_type) { |
|
328 | 328 | $this->query_modifier = new EventEspresso\Core\CPTs\CptQueryModifier( |
329 | 329 | $post_type, |
330 | - $this->_CPTs[ $post_type ], |
|
330 | + $this->_CPTs[$post_type], |
|
331 | 331 | $WP_Query, |
332 | 332 | EE_Registry::instance()->REQ |
333 | 333 | ); |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * @param $SQL |
371 | 371 | * @return string |
372 | 372 | */ |
373 | - public function posts_fields( $SQL ) { |
|
374 | - if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) { |
|
375 | - return $this->query_modifier->postsFields( $SQL ); |
|
373 | + public function posts_fields($SQL) { |
|
374 | + if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) { |
|
375 | + return $this->query_modifier->postsFields($SQL); |
|
376 | 376 | } |
377 | 377 | return $SQL; |
378 | 378 | } |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | * @param $SQL |
387 | 387 | * @return string |
388 | 388 | */ |
389 | - public function posts_join( $SQL ) { |
|
390 | - if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) { |
|
391 | - return $this->query_modifier->postsJoin( $SQL ); |
|
389 | + public function posts_join($SQL) { |
|
390 | + if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) { |
|
391 | + return $this->query_modifier->postsJoin($SQL); |
|
392 | 392 | } |
393 | 393 | return $SQL; |
394 | 394 | } |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | * @param \WP_Post[] $posts |
403 | 403 | * @return \WP_Post[] |
404 | 404 | */ |
405 | - public function the_posts( $posts ) { |
|
406 | - if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) { |
|
407 | - $this->query_modifier->thePosts( $posts ); |
|
405 | + public function the_posts($posts) { |
|
406 | + if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) { |
|
407 | + $this->query_modifier->thePosts($posts); |
|
408 | 408 | } |
409 | 409 | return $posts; |
410 | 410 | } |
@@ -419,9 +419,9 @@ discard block |
||
419 | 419 | * @param $ID |
420 | 420 | * @return string |
421 | 421 | */ |
422 | - public function get_edit_post_link( $url, $ID ) { |
|
423 | - if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) { |
|
424 | - return $this->query_modifier->getEditPostLink( $url, $ID ); |
|
422 | + public function get_edit_post_link($url, $ID) { |
|
423 | + if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) { |
|
424 | + return $this->query_modifier->getEditPostLink($url, $ID); |
|
425 | 425 | } |
426 | 426 | return ''; |
427 | 427 | } |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * @access public |
435 | 435 | * @param null $WP_Query |
436 | 436 | */ |
437 | - protected function _do_template_filters( $WP_Query = null ) { |
|
438 | - if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) { |
|
437 | + protected function _do_template_filters($WP_Query = null) { |
|
438 | + if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) { |
|
439 | 439 | $this->query_modifier->addTemplateFilters(); |
440 | 440 | } |
441 | 441 | } |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | * @param string $current_template Existing default template path derived for this page call. |
450 | 450 | * @return string the path to the full template file. |
451 | 451 | */ |
452 | - public function single_cpt_template( $current_template ) { |
|
453 | - if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) { |
|
454 | - return $this->query_modifier->singleCptTemplate( $current_template ); |
|
452 | + public function single_cpt_template($current_template) { |
|
453 | + if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) { |
|
454 | + return $this->query_modifier->singleCptTemplate($current_template); |
|
455 | 455 | } |
456 | 456 | return $current_template; |
457 | 457 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @return string |
54 | 54 | * @throws \EE_Error |
55 | 55 | */ |
56 | - public static function get_valid_timezone_string( $timezone_string = '' ) { |
|
56 | + public static function get_valid_timezone_string($timezone_string = '') { |
|
57 | 57 | // if passed a value, then use that, else get WP option |
58 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
58 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
59 | 59 | // value from above exists, use that, else get timezone string from gmt_offset |
60 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | - EEH_DTT_Helper::validate_timezone( $timezone_string ); |
|
60 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | + EEH_DTT_Helper::validate_timezone($timezone_string); |
|
62 | 62 | return $timezone_string; |
63 | 63 | } |
64 | 64 | |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | * @return bool |
75 | 75 | * @throws \EE_Error |
76 | 76 | */ |
77 | - public static function validate_timezone( $timezone_string, $throw_error = true ) { |
|
77 | + public static function validate_timezone($timezone_string, $throw_error = true) { |
|
78 | 78 | // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it |
79 | 79 | try { |
80 | - new DateTimeZone( $timezone_string ); |
|
81 | - } catch ( Exception $e ) { |
|
80 | + new DateTimeZone($timezone_string); |
|
81 | + } catch (Exception $e) { |
|
82 | 82 | // sometimes we take exception to exceptions |
83 | - if ( ! $throw_error ) { |
|
83 | + if ( ! $throw_error) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | throw new EE_Error( |
87 | 87 | sprintf( |
88 | - __( 'The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
88 | + __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
89 | 89 | $timezone_string, |
90 | 90 | '<a href="http://www.php.net/manual/en/timezones.php">', |
91 | 91 | '</a>' |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | * @param string $gmt_offset |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function get_timezone_string_from_gmt_offset( $gmt_offset = '' ) { |
|
107 | + public static function get_timezone_string_from_gmt_offset($gmt_offset = '') { |
|
108 | 108 | $timezone_string = 'UTC'; |
109 | - $gmt_offset = ! empty( $gmt_offset ) ? $gmt_offset : get_option( 'gmt_offset' ); |
|
110 | - if ( $gmt_offset !== '' ) { |
|
109 | + $gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset'); |
|
110 | + if ($gmt_offset !== '') { |
|
111 | 111 | // convert GMT offset to seconds |
112 | 112 | $gmt_offset = $gmt_offset * HOUR_IN_SECONDS; |
113 | 113 | // account for WP offsets that aren't valid UTC |
114 | - $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets( $gmt_offset ); |
|
114 | + $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset); |
|
115 | 115 | // although we don't know the TZ abbreviation, we know the UTC offset |
116 | - $timezone_string = timezone_name_from_abbr( null, $gmt_offset ); |
|
116 | + $timezone_string = timezone_name_from_abbr(null, $gmt_offset); |
|
117 | 117 | } |
118 | 118 | // better have a valid timezone string by now, but if not, sigh... loop thru the timezone_abbreviations_list()... |
119 | - $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset ); |
|
119 | + $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset); |
|
120 | 120 | return $timezone_string; |
121 | 121 | } |
122 | 122 | |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | * @return int seconds offset |
128 | 128 | */ |
129 | 129 | public static function get_site_timezone_gmt_offset() { |
130 | - $timezone_string = get_option( 'timezone_string' ); |
|
131 | - if ( $timezone_string ) { |
|
130 | + $timezone_string = get_option('timezone_string'); |
|
131 | + if ($timezone_string) { |
|
132 | 132 | try { |
133 | - $timezone = new DateTimeZone( $timezone_string ); |
|
134 | - return $timezone->getOffset( new DateTime() ); //in WordPress DateTime defaults to UTC |
|
135 | - } catch( Exception $e ){} |
|
133 | + $timezone = new DateTimeZone($timezone_string); |
|
134 | + return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC |
|
135 | + } catch (Exception $e) {} |
|
136 | 136 | } |
137 | - $offset = get_option( 'gmt_offset' ); |
|
138 | - return (int) ( $offset * HOUR_IN_SECONDS ); |
|
137 | + $offset = get_option('gmt_offset'); |
|
138 | + return (int) ($offset * HOUR_IN_SECONDS); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | * @param int $gmt_offset |
148 | 148 | * @return int |
149 | 149 | */ |
150 | - public static function adjust_invalid_gmt_offsets( $gmt_offset = 0 ) { |
|
150 | + public static function adjust_invalid_gmt_offsets($gmt_offset = 0) { |
|
151 | 151 | //make sure $gmt_offset is int |
152 | 152 | $gmt_offset = (int) $gmt_offset; |
153 | - switch ( $gmt_offset ) { |
|
153 | + switch ($gmt_offset) { |
|
154 | 154 | |
155 | 155 | // case -30600 : |
156 | 156 | // $gmt_offset = -28800; |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | * @return string |
203 | 203 | * @throws \EE_Error |
204 | 204 | */ |
205 | - public static function get_timezone_string_from_abbreviations_list( $gmt_offset = 0 ) { |
|
205 | + public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) { |
|
206 | 206 | $abbreviations = timezone_abbreviations_list(); |
207 | - foreach ( $abbreviations as $abbreviation ) { |
|
208 | - foreach ( $abbreviation as $city ) { |
|
209 | - if ( $city['offset'] === $gmt_offset && $city['dst'] === FALSE ) { |
|
207 | + foreach ($abbreviations as $abbreviation) { |
|
208 | + foreach ($abbreviation as $city) { |
|
209 | + if ($city['offset'] === $gmt_offset && $city['dst'] === FALSE) { |
|
210 | 210 | // check if the timezone is valid but don't throw any errors if it isn't |
211 | - if ( EEH_DTT_Helper::validate_timezone( $city['timezone_id'], false ) ) { |
|
211 | + if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
212 | 212 | return $city['timezone_id']; |
213 | 213 | } |
214 | 214 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | throw new EE_Error( |
218 | 218 | sprintf( |
219 | - __( 'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
219 | + __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
220 | 220 | $gmt_offset, |
221 | 221 | '<a href="http://www.php.net/manual/en/timezones.php">', |
222 | 222 | '</a>' |
@@ -230,23 +230,23 @@ discard block |
||
230 | 230 | * @access public |
231 | 231 | * @param string $timezone_string |
232 | 232 | */ |
233 | - public static function timezone_select_input( $timezone_string = '' ) { |
|
233 | + public static function timezone_select_input($timezone_string = '') { |
|
234 | 234 | // get WP date time format |
235 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
235 | + $datetime_format = get_option('date_format').' '.get_option('time_format'); |
|
236 | 236 | // if passed a value, then use that, else get WP option |
237 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
237 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
238 | 238 | // check if the timezone is valid but don't throw any errors if it isn't |
239 | - $timezone_string = EEH_DTT_Helper::validate_timezone( $timezone_string, false ); |
|
239 | + $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
240 | 240 | $gmt_offset = get_option('gmt_offset'); |
241 | 241 | |
242 | 242 | $check_zone_info = true; |
243 | - if ( empty( $timezone_string )) { |
|
243 | + if (empty($timezone_string)) { |
|
244 | 244 | // Create a UTC+- zone if no timezone string exists |
245 | 245 | $check_zone_info = false; |
246 | - if ( $gmt_offset > 0 ) { |
|
247 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
248 | - } elseif ( $gmt_offset < 0 ) { |
|
249 | - $timezone_string = 'UTC' . $gmt_offset; |
|
246 | + if ($gmt_offset > 0) { |
|
247 | + $timezone_string = 'UTC+'.$gmt_offset; |
|
248 | + } elseif ($gmt_offset < 0) { |
|
249 | + $timezone_string = 'UTC'.$gmt_offset; |
|
250 | 250 | } else { |
251 | 251 | $timezone_string = 'UTC'; |
252 | 252 | } |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | __('%1$sUTC%2$s time is %3$s'), |
269 | 269 | '<abbr title="Coordinated Universal Time">', |
270 | 270 | '</abbr>', |
271 | - '<code>' . date_i18n( $datetime_format , false, 'gmt') . '</code>' |
|
271 | + '<code>'.date_i18n($datetime_format, false, 'gmt').'</code>' |
|
272 | 272 | ); |
273 | 273 | ?></span> |
274 | - <?php if ( ! empty( $timezone_string ) || ! empty( $gmt_offset )) : ?> |
|
275 | - <br /><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n( $datetime_format ) . '</code>' ); ?></span> |
|
274 | + <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
275 | + <br /><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span> |
|
276 | 276 | <?php endif; ?> |
277 | 277 | |
278 | 278 | <?php if ($check_zone_info && $timezone_string) : ?> |
@@ -304,10 +304,9 @@ discard block |
||
304 | 304 | |
305 | 305 | if ($found) { |
306 | 306 | $message = $tr['isdst'] ? |
307 | - __(' Daylight saving time begins on: %s.' ) : |
|
308 | - __(' Standard time begins on: %s.'); |
|
307 | + __(' Daylight saving time begins on: %s.') : __(' Standard time begins on: %s.'); |
|
309 | 308 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
310 | - printf( $message, '<code >' . date_i18n( $datetime_format, $tr['ts'] + ( $tz_offset - $tr['offset'] ) ). '</code >' ); |
|
309 | + printf($message, '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >'); |
|
311 | 310 | } else { |
312 | 311 | _e('This timezone does not observe daylight saving time.'); |
313 | 312 | } |
@@ -337,14 +336,14 @@ discard block |
||
337 | 336 | * |
338 | 337 | * @return int $unix_timestamp with the offset applied for the given timezone. |
339 | 338 | */ |
340 | - public static function get_timestamp_with_offset( $unix_timestamp = 0, $timezone_string = '' ) { |
|
339 | + public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') { |
|
341 | 340 | $unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp; |
342 | - $timezone_string = self::get_valid_timezone_string( $timezone_string ); |
|
343 | - $TimeZone = new DateTimeZone( $timezone_string ); |
|
341 | + $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
342 | + $TimeZone = new DateTimeZone($timezone_string); |
|
344 | 343 | |
345 | - $DateTime = new DateTime( '@' . $unix_timestamp, $TimeZone ); |
|
346 | - $offset = timezone_offset_get( $TimeZone, $DateTime ); |
|
347 | - return (int)$DateTime->format( 'U' ) + (int)$offset; |
|
344 | + $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone); |
|
345 | + $offset = timezone_offset_get($TimeZone, $DateTime); |
|
346 | + return (int) $DateTime->format('U') + (int) $offset; |
|
348 | 347 | } |
349 | 348 | |
350 | 349 | |
@@ -359,17 +358,17 @@ discard block |
||
359 | 358 | * @param string $datetime_field_name the datetime fieldname to be manipulated |
360 | 359 | * @return EE_Base_Class |
361 | 360 | */ |
362 | - protected static function _set_date_time_field( EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name ) { |
|
361 | + protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) { |
|
363 | 362 | // grab current datetime format |
364 | 363 | $current_format = $obj->get_format(); |
365 | 364 | // set new full timestamp format |
366 | - $obj->set_date_format( EE_Datetime_Field::mysql_date_format ); |
|
367 | - $obj->set_time_format( EE_Datetime_Field::mysql_time_format ); |
|
365 | + $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
366 | + $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
368 | 367 | // set the new date value using a full timestamp format so that no data is lost |
369 | - $obj->set( $datetime_field_name, $DateTime->format( EE_Datetime_Field::mysql_timestamp_format ) ); |
|
368 | + $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
370 | 369 | // reset datetime formats |
371 | - $obj->set_date_format( $current_format[0] ); |
|
372 | - $obj->set_time_format( $current_format[1] ); |
|
370 | + $obj->set_date_format($current_format[0]); |
|
371 | + $obj->set_time_format($current_format[1]); |
|
373 | 372 | return $obj; |
374 | 373 | } |
375 | 374 | |
@@ -386,11 +385,11 @@ discard block |
||
386 | 385 | * @param integer $value what you want to increment the time by |
387 | 386 | * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it (chaining) |
388 | 387 | */ |
389 | - public static function date_time_add( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
388 | + public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
390 | 389 | //get the raw UTC date. |
391 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
392 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value ); |
|
393 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
390 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
391 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
392 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
394 | 393 | } |
395 | 394 | |
396 | 395 | |
@@ -405,11 +404,11 @@ discard block |
||
405 | 404 | * @param int $value |
406 | 405 | * @return \EE_Base_Class |
407 | 406 | */ |
408 | - public static function date_time_subtract( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
407 | + public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
409 | 408 | //get the raw UTC date |
410 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
411 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value, '-' ); |
|
412 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
409 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
410 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
411 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
413 | 412 | } |
414 | 413 | |
415 | 414 | |
@@ -422,44 +421,44 @@ discard block |
||
422 | 421 | * @return \DateTime return whatever type came in. |
423 | 422 | * @throws \EE_Error |
424 | 423 | */ |
425 | - protected static function _modify_datetime_object( DateTime $DateTime, $period = 'years', $value = 1, $operand = '+' ) { |
|
426 | - if ( ! $DateTime instanceof DateTime ) { |
|
424 | + protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') { |
|
425 | + if ( ! $DateTime instanceof DateTime) { |
|
427 | 426 | throw new EE_Error( |
428 | 427 | sprintf( |
429 | - __( 'Expected a PHP DateTime object, but instead received %1$s', 'event_espresso' ), |
|
430 | - print_r( $DateTime, true ) |
|
428 | + __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
429 | + print_r($DateTime, true) |
|
431 | 430 | ) |
432 | 431 | ); |
433 | 432 | } |
434 | - switch ( $period ) { |
|
433 | + switch ($period) { |
|
435 | 434 | case 'years' : |
436 | - $value = 'P' . $value . 'Y'; |
|
435 | + $value = 'P'.$value.'Y'; |
|
437 | 436 | break; |
438 | 437 | case 'months' : |
439 | - $value = 'P' . $value . 'M'; |
|
438 | + $value = 'P'.$value.'M'; |
|
440 | 439 | break; |
441 | 440 | case 'weeks' : |
442 | - $value = 'P' . $value . 'W'; |
|
441 | + $value = 'P'.$value.'W'; |
|
443 | 442 | break; |
444 | 443 | case 'days' : |
445 | - $value = 'P' . $value . 'D'; |
|
444 | + $value = 'P'.$value.'D'; |
|
446 | 445 | break; |
447 | 446 | case 'hours' : |
448 | - $value = 'PT' . $value . 'H'; |
|
447 | + $value = 'PT'.$value.'H'; |
|
449 | 448 | break; |
450 | 449 | case 'minutes' : |
451 | - $value = 'PT' . $value . 'M'; |
|
450 | + $value = 'PT'.$value.'M'; |
|
452 | 451 | break; |
453 | 452 | case 'seconds' : |
454 | - $value = 'PT' . $value . 'S'; |
|
453 | + $value = 'PT'.$value.'S'; |
|
455 | 454 | break; |
456 | 455 | } |
457 | - switch ( $operand ) { |
|
456 | + switch ($operand) { |
|
458 | 457 | case '+': |
459 | - $DateTime->add( new DateInterval( $value ) ); |
|
458 | + $DateTime->add(new DateInterval($value)); |
|
460 | 459 | break; |
461 | 460 | case '-': |
462 | - $DateTime->sub( new DateInterval( $value ) ); |
|
461 | + $DateTime->sub(new DateInterval($value)); |
|
463 | 462 | break; |
464 | 463 | } |
465 | 464 | return $DateTime; |
@@ -475,16 +474,16 @@ discard block |
||
475 | 474 | * @return \DateTime return whatever type came in. |
476 | 475 | * @throws \EE_Error |
477 | 476 | */ |
478 | - protected static function _modify_timestamp( $timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
479 | - if ( ! preg_match( EE_Datetime_Field::unix_timestamp_regex, $timestamp ) ) { |
|
477 | + protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
478 | + if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
480 | 479 | throw new EE_Error( |
481 | 480 | sprintf( |
482 | - __( 'Expected a Unix timestamp, but instead received %1$s', 'event_espresso' ), |
|
483 | - print_r( $timestamp, true ) |
|
481 | + __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
482 | + print_r($timestamp, true) |
|
484 | 483 | ) |
485 | 484 | ); |
486 | 485 | } |
487 | - switch ( $period ) { |
|
486 | + switch ($period) { |
|
488 | 487 | case 'years' : |
489 | 488 | $value = YEAR_IN_SECONDS * $value; |
490 | 489 | break; |
@@ -504,9 +503,9 @@ discard block |
||
504 | 503 | $value = MINUTE_IN_SECONDS * $value; |
505 | 504 | break; |
506 | 505 | } |
507 | - switch ( $operand ) { |
|
506 | + switch ($operand) { |
|
508 | 507 | case '+': |
509 | - $timestamp += $value; |
|
508 | + $timestamp += $value; |
|
510 | 509 | break; |
511 | 510 | case '-': |
512 | 511 | $timestamp -= $value; |
@@ -526,11 +525,11 @@ discard block |
||
526 | 525 | * @param string $operand What operand you wish to use for the calculation |
527 | 526 | * @return mixed string|DateTime return whatever type came in. |
528 | 527 | */ |
529 | - public static function calc_date( $DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
530 | - if ( $DateTime_or_timestamp instanceof DateTime ) { |
|
531 | - return EEH_DTT_Helper::_modify_datetime_object( $DateTime_or_timestamp, $period, $value, $operand ); |
|
532 | - } else if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp )) { |
|
533 | - return EEH_DTT_Helper::_modify_timestamp( $DateTime_or_timestamp, $period, $value, $operand ); |
|
528 | + public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
529 | + if ($DateTime_or_timestamp instanceof DateTime) { |
|
530 | + return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
531 | + } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
532 | + return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
534 | 533 | } else { |
535 | 534 | //error |
536 | 535 | return $DateTime_or_timestamp; |
@@ -560,24 +559,24 @@ discard block |
||
560 | 559 | * 'moment' => //date and time format. |
561 | 560 | * ) |
562 | 561 | */ |
563 | - public static function convert_php_to_js_and_moment_date_formats( $date_format_string = null, $time_format_string = null ) { |
|
564 | - if ( $date_format_string === null ) { |
|
565 | - $date_format_string = get_option( 'date_format' ); |
|
562 | + public static function convert_php_to_js_and_moment_date_formats($date_format_string = null, $time_format_string = null) { |
|
563 | + if ($date_format_string === null) { |
|
564 | + $date_format_string = get_option('date_format'); |
|
566 | 565 | } |
567 | 566 | |
568 | - if ( $time_format_string === null ) { |
|
569 | - $time_format_string = get_option( 'time_format' ); |
|
567 | + if ($time_format_string === null) { |
|
568 | + $time_format_string = get_option('time_format'); |
|
570 | 569 | } |
571 | 570 | |
572 | - $date_format = self::_php_to_js_moment_converter( $date_format_string ); |
|
573 | - $time_format = self::_php_to_js_moment_converter( $time_format_string ); |
|
571 | + $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
572 | + $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
574 | 573 | |
575 | 574 | return array( |
576 | 575 | 'js' => array( |
577 | 576 | 'date' => $date_format['js'], |
578 | 577 | 'time' => $time_format['js'] |
579 | 578 | ), |
580 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment' ] |
|
579 | + 'moment' => $date_format['moment'].' '.$time_format['moment'] |
|
581 | 580 | ); |
582 | 581 | } |
583 | 582 | |
@@ -591,7 +590,7 @@ discard block |
||
591 | 590 | * |
592 | 591 | * @return array js and moment formats. |
593 | 592 | */ |
594 | - protected static function _php_to_js_moment_converter( $format_string ) { |
|
593 | + protected static function _php_to_js_moment_converter($format_string) { |
|
595 | 594 | /** |
596 | 595 | * This is a map of symbols for formats. |
597 | 596 | * The index is the php symbol, the equivalent values are in the array. |
@@ -748,15 +747,15 @@ discard block |
||
748 | 747 | $jquery_ui_format = ""; |
749 | 748 | $moment_format = ""; |
750 | 749 | $escaping = false; |
751 | - for ( $i = 0; $i < strlen($format_string); $i++ ) { |
|
750 | + for ($i = 0; $i < strlen($format_string); $i++) { |
|
752 | 751 | $char = $format_string[$i]; |
753 | - if ( $char === '\\' ) { // PHP date format escaping character |
|
752 | + if ($char === '\\') { // PHP date format escaping character |
|
754 | 753 | $i++; |
755 | - if ( $escaping ) { |
|
754 | + if ($escaping) { |
|
756 | 755 | $jquery_ui_format .= $format_string[$i]; |
757 | 756 | $moment_format .= $format_string[$i]; |
758 | 757 | } else { |
759 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
758 | + $jquery_ui_format .= '\''.$format_string[$i]; |
|
760 | 759 | $moment_format .= $format_string[$i]; |
761 | 760 | } |
762 | 761 | $escaping = true; |
@@ -775,7 +774,7 @@ discard block |
||
775 | 774 | } |
776 | 775 | } |
777 | 776 | } |
778 | - return array( 'js' => $jquery_ui_format, 'moment' => $moment_format ); |
|
777 | + return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
779 | 778 | } |
780 | 779 | |
781 | 780 | |
@@ -790,25 +789,25 @@ discard block |
||
790 | 789 | * errors is returned. So for client code calling, check for is_array() to |
791 | 790 | * indicate failed validations. |
792 | 791 | */ |
793 | - public static function validate_format_string( $format_string ) { |
|
792 | + public static function validate_format_string($format_string) { |
|
794 | 793 | $error_msg = array(); |
795 | 794 | //time format checks |
796 | - switch ( true ) { |
|
797 | - case strpos( $format_string, 'h' ) !== false : |
|
798 | - case strpos( $format_string, 'g' ) !== false : |
|
795 | + switch (true) { |
|
796 | + case strpos($format_string, 'h') !== false : |
|
797 | + case strpos($format_string, 'g') !== false : |
|
799 | 798 | /** |
800 | 799 | * if the time string has a lowercase 'h' which == 12 hour time format and there |
801 | 800 | * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
802 | 801 | * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
803 | 802 | */ |
804 | - if ( strpos( strtoupper( $format_string ), 'A' ) === false ) { |
|
805 | - $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso' ); |
|
803 | + if (strpos(strtoupper($format_string), 'A') === false) { |
|
804 | + $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso'); |
|
806 | 805 | } |
807 | 806 | break; |
808 | 807 | |
809 | 808 | } |
810 | 809 | |
811 | - return empty( $error_msg ) ? true : $error_msg; |
|
810 | + return empty($error_msg) ? true : $error_msg; |
|
812 | 811 | } |
813 | 812 | |
814 | 813 | |
@@ -830,11 +829,11 @@ discard block |
||
830 | 829 | * @param mixed $date_2 |
831 | 830 | * @return bool |
832 | 831 | */ |
833 | - public static function dates_represent_one_24_hour_date( $date_1, $date_2 ) { |
|
832 | + public static function dates_represent_one_24_hour_date($date_1, $date_2) { |
|
834 | 833 | |
835 | 834 | if ( |
836 | - ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime ) || |
|
837 | - ( $date_1->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' || $date_2->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' ) |
|
835 | + ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
836 | + ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
838 | 837 | ) { |
839 | 838 | return false; |
840 | 839 | } |
@@ -851,11 +850,11 @@ discard block |
||
851 | 850 | * @param string $field_for_interval The Database field that is the interval is applied to in the query. |
852 | 851 | * @return string |
853 | 852 | */ |
854 | - public static function get_sql_query_interval_for_offset( $timezone_string, $field_for_interval ) { |
|
853 | + public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) { |
|
855 | 854 | try { |
856 | 855 | /** need to account for timezone offset on the selects */ |
857 | - $DateTimeZone = new DateTimeZone( $timezone_string ); |
|
858 | - } catch ( Exception $e ) { |
|
856 | + $DateTimeZone = new DateTimeZone($timezone_string); |
|
857 | + } catch (Exception $e) { |
|
859 | 858 | $DateTimeZone = null; |
860 | 859 | } |
861 | 860 | |
@@ -863,10 +862,10 @@ discard block |
||
863 | 862 | * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds. |
864 | 863 | * Hence we do the calc for DateTimeZone::getOffset. |
865 | 864 | */ |
866 | - $offset = $DateTimeZone instanceof DateTimeZone ? ( $DateTimeZone->getOffset( new DateTime('now') ) ) / HOUR_IN_SECONDS : get_option( 'gmt_offset' ); |
|
865 | + $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
|
867 | 866 | $query_interval = $offset < 0 |
868 | - ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset*-1 . ' HOUR)' |
|
869 | - : 'DATE_ADD(' . $field_for_interval .', INTERVAL ' . $offset . ' HOUR)'; |
|
867 | + ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)' |
|
868 | + : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)'; |
|
870 | 869 | return $query_interval; |
871 | 870 | } |
872 | 871 | |
@@ -878,47 +877,47 @@ discard block |
||
878 | 877 | * @return string |
879 | 878 | */ |
880 | 879 | public static function get_timezone_string_for_display() { |
881 | - $pretty_timezone = apply_filters( 'FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '' ); |
|
882 | - if( ! empty( $pretty_timezone ) ) { |
|
883 | - return esc_html( $pretty_timezone ); |
|
880 | + $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
|
881 | + if ( ! empty($pretty_timezone)) { |
|
882 | + return esc_html($pretty_timezone); |
|
884 | 883 | } |
885 | - $timezone_string = get_option( 'timezone_string' ); |
|
886 | - if( $timezone_string ) { |
|
884 | + $timezone_string = get_option('timezone_string'); |
|
885 | + if ($timezone_string) { |
|
887 | 886 | static $mo_loaded = false; |
888 | 887 | // Load translations for continents and cities just like wp_timezone_choice does |
889 | - if ( ! $mo_loaded ) { |
|
888 | + if ( ! $mo_loaded) { |
|
890 | 889 | $locale = get_locale(); |
891 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
892 | - load_textdomain( 'continents-cities', $mofile ); |
|
890 | + $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo'; |
|
891 | + load_textdomain('continents-cities', $mofile); |
|
893 | 892 | $mo_loaded = true; |
894 | 893 | } |
895 | 894 | //well that was easy. |
896 | - $parts = explode('/', $timezone_string ); |
|
895 | + $parts = explode('/', $timezone_string); |
|
897 | 896 | //remove the continent |
898 | - unset( $parts[0] ); |
|
897 | + unset($parts[0]); |
|
899 | 898 | $t_parts = array(); |
900 | - foreach( $parts as $part ) { |
|
901 | - $t_parts[] = translate( str_replace( '_', ' ', $part ), 'continents-cities' ); |
|
899 | + foreach ($parts as $part) { |
|
900 | + $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities'); |
|
902 | 901 | } |
903 | - return implode( ' - ', $t_parts ); |
|
902 | + return implode(' - ', $t_parts); |
|
904 | 903 | } |
905 | 904 | //they haven't set the timezone string, so let's return a string like "UTC+1" |
906 | - $gmt_offset = get_option( 'gmt_offset' ); |
|
907 | - if( intval( $gmt_offset ) >= 0 ) { |
|
905 | + $gmt_offset = get_option('gmt_offset'); |
|
906 | + if (intval($gmt_offset) >= 0) { |
|
908 | 907 | $prefix = '+'; |
909 | 908 | } else { |
910 | 909 | $prefix = ''; |
911 | 910 | } |
912 | - $parts = explode( '.', (string) $gmt_offset ); |
|
913 | - if( count( $parts ) === 1 ) { |
|
911 | + $parts = explode('.', (string) $gmt_offset); |
|
912 | + if (count($parts) === 1) { |
|
914 | 913 | $parts[1] = '00'; |
915 | 914 | } else { |
916 | 915 | //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
917 | 916 | //to minutes, eg 30 or 15, respectively |
918 | - $hour_fraction = (float)( '0.' . $parts[1] ); |
|
919 | - $parts[1] = (string)$hour_fraction * 60; |
|
917 | + $hour_fraction = (float) ('0.'.$parts[1]); |
|
918 | + $parts[1] = (string) $hour_fraction * 60; |
|
920 | 919 | } |
921 | - return sprintf( __( 'UTC%1$s', 'event_espresso' ), $prefix . implode( ':', $parts ) ); |
|
920 | + return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts)); |
|
922 | 921 | } |
923 | 922 | |
924 | 923 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | * @param string $email_address |
15 | 15 | * @return string |
16 | 16 | */ |
17 | - function prepare_for_set($email_address ) { |
|
17 | + function prepare_for_set($email_address) { |
|
18 | 18 | $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
19 | 19 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
20 | 20 | : 'wp_default'; |
@@ -15,27 +15,27 @@ |
||
15 | 15 | * @type bool $show_gravatar whether to show gravatar or not. |
16 | 16 | */ |
17 | 17 | |
18 | -$no_attendees_message = apply_filters( 'FHEE__loop-espresso_attendees-shortcode__template__no_attendees_message', __('No Attendees Yet', 'event_espresso' ) ); |
|
18 | +$no_attendees_message = apply_filters('FHEE__loop-espresso_attendees-shortcode__template__no_attendees_message', __('No Attendees Yet', 'event_espresso')); |
|
19 | 19 | |
20 | 20 | |
21 | 21 | ?> |
22 | 22 | |
23 | 23 | <div class="event-attendees"> |
24 | - <?php do_action( 'AHEE__loop-espresso_event_attendees__before', $contacts, $event, $datetime, $ticket, $show_gravatar ); ?> |
|
25 | - <?php if ( $contacts ) : ?> |
|
24 | + <?php do_action('AHEE__loop-espresso_event_attendees__before', $contacts, $event, $datetime, $ticket, $show_gravatar); ?> |
|
25 | + <?php if ($contacts) : ?> |
|
26 | 26 | <ul class="event-attendees-list"> |
27 | - <?php foreach( $contacts as $contact ) : |
|
28 | - EEH_Template::get_template_part( 'content', 'espresso_event_attendees', array( |
|
27 | + <?php foreach ($contacts as $contact) : |
|
28 | + EEH_Template::get_template_part('content', 'espresso_event_attendees', array( |
|
29 | 29 | 'contact' => $contact, |
30 | 30 | 'event' => $event, |
31 | 31 | 'datetime' => $datetime, |
32 | 32 | 'ticket' => $ticket, |
33 | 33 | 'show_gravatar' => $show_gravatar |
34 | - ) ); |
|
34 | + )); |
|
35 | 35 | endforeach; ?> |
36 | 36 | </ul> |
37 | 37 | <?php else : ?> |
38 | 38 | <p><?php echo $no_attendees_message; ?></p> |
39 | 39 | <?php endif; ?> |
40 | - <?php do_action( 'AHEE__loop-espresso_event_attendees__after', $contacts, $event, $datetime, $ticket, $show_gravatar ); ?> |
|
40 | + <?php do_action('AHEE__loop-espresso_event_attendees__after', $contacts, $event, $datetime, $ticket, $show_gravatar); ?> |
|
41 | 41 | </div> |
42 | 42 | \ No newline at end of file |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param int $PAY_ID |
171 | 171 | */ |
172 | 172 | public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) { |
173 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
173 | + do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
174 | 174 | if ( absint( $TXN_ID )) { |
175 | 175 | self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID; |
176 | 176 | add_action( |
@@ -303,7 +303,6 @@ discard block |
||
303 | 303 | |
304 | 304 | /** |
305 | 305 | * finalize_abandoned_transactions |
306 | - |
|
307 | 306 | * loops through the self::$_abandoned_transactions array |
308 | 307 | * and attempts to finalize any TXNs that have not been completed |
309 | 308 | * but have had their sessions expired, most likely due to a user not |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @return EE_Cron_Tasks |
29 | 29 | */ |
30 | 30 | public static function instance() { |
31 | - if ( ! self::$_instance instanceof EE_Cron_Tasks ) { |
|
31 | + if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
32 | 32 | self::$_instance = new self(); |
33 | 33 | } |
34 | 34 | return self::$_instance; |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * @return EE_Cron_Tasks |
42 | 42 | */ |
43 | 43 | private function __construct() { |
44 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
44 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
45 | 45 | // verify that WP Cron is enabled |
46 | - if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON && is_admin() ) { |
|
46 | + if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON && is_admin()) { |
|
47 | 47 | EE_Error::add_persistent_admin_notice( |
48 | 48 | 'wp_cron_disabled', |
49 | 49 | sprintf( |
@@ -58,26 +58,26 @@ discard block |
||
58 | 58 | // UPDATE TRANSACTION WITH PAYMENT |
59 | 59 | add_action( |
60 | 60 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
61 | - array( 'EE_Cron_Tasks', 'setup_update_for_transaction_with_payment' ), |
|
61 | + array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
62 | 62 | 10, 2 |
63 | 63 | ); |
64 | 64 | // FINALIZE ABANDONED TRANSACTIONS |
65 | 65 | add_action( |
66 | 66 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
67 | - array( 'EE_Cron_Tasks', 'check_for_abandoned_transactions' ), |
|
67 | + array('EE_Cron_Tasks', 'check_for_abandoned_transactions'), |
|
68 | 68 | 10, 1 |
69 | 69 | ); |
70 | 70 | // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
71 | 71 | add_action( |
72 | 72 | 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
73 | - array( 'EE_Cron_Tasks', 'clean_out_junk_transactions' ) |
|
73 | + array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
74 | 74 | ); |
75 | 75 | // logging |
76 | 76 | add_action( |
77 | 77 | 'AHEE__EE_System__load_core_configuration__complete', |
78 | - array( 'EE_Cron_Tasks', 'log_scheduled_ee_crons' ) |
|
78 | + array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
79 | 79 | ); |
80 | - EE_Registry::instance()->load_lib( 'Messages_Scheduler' ); |
|
80 | + EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
93 | 93 | 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
94 | 94 | ); |
95 | - $crons = get_option( 'cron' ); |
|
96 | - if ( ! is_array( $crons ) ) { |
|
95 | + $crons = get_option('cron'); |
|
96 | + if ( ! is_array($crons)) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | - foreach ( $crons as $timestamp => $cron ) { |
|
100 | - foreach ( $ee_crons as $ee_cron ) { |
|
101 | - if ( isset( $cron[ $ee_cron ] ) ) { |
|
102 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron' ); |
|
103 | - foreach ( $cron[ $ee_cron ] as $ee_cron_details ) { |
|
104 | - if ( ! empty( $ee_cron_details[ 'args' ] )) { |
|
105 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, print_r( $ee_cron_details[ 'args' ], true ), "$ee_cron args" ); |
|
99 | + foreach ($crons as $timestamp => $cron) { |
|
100 | + foreach ($ee_crons as $ee_cron) { |
|
101 | + if (isset($cron[$ee_cron])) { |
|
102 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
103 | + foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
104 | + if ( ! empty($ee_cron_details['args'])) { |
|
105 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, print_r($ee_cron_details['args'], true), "$ee_cron args"); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | $TXN_ID, |
140 | 140 | $PAY_ID |
141 | 141 | ) { |
142 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
142 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
143 | 143 | // validate $TXN_ID and $timestamp |
144 | - $TXN_ID = absint( $TXN_ID ); |
|
145 | - $timestamp = absint( $timestamp ); |
|
146 | - if ( $TXN_ID && $timestamp ) { |
|
144 | + $TXN_ID = absint($TXN_ID); |
|
145 | + $timestamp = absint($timestamp); |
|
146 | + if ($TXN_ID && $timestamp) { |
|
147 | 147 | wp_schedule_single_event( |
148 | 148 | $timestamp, |
149 | 149 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
150 | - array( $TXN_ID, $PAY_ID ) |
|
150 | + array($TXN_ID, $PAY_ID) |
|
151 | 151 | ); |
152 | 152 | } |
153 | 153 | } |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | * @param int $TXN_ID |
170 | 170 | * @param int $PAY_ID |
171 | 171 | */ |
172 | - public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) { |
|
173 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
174 | - if ( absint( $TXN_ID )) { |
|
175 | - self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID; |
|
172 | + public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) { |
|
173 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
174 | + if (absint($TXN_ID)) { |
|
175 | + self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
176 | 176 | add_action( |
177 | 177 | 'shutdown', |
178 | - array( 'EE_Cron_Tasks', 'update_transaction_with_payment' ), |
|
178 | + array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
179 | 179 | 5 |
180 | 180 | ); |
181 | 181 | } |
@@ -194,18 +194,18 @@ discard block |
||
194 | 194 | * @throws \EE_Error |
195 | 195 | */ |
196 | 196 | public static function update_transaction_with_payment() { |
197 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
197 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
198 | 198 | // are there any TXNs that need cleaning up ? |
199 | - if ( ! empty( self::$_update_transactions_with_payment ) ) { |
|
199 | + if ( ! empty(self::$_update_transactions_with_payment)) { |
|
200 | 200 | /** @type EE_Payment_Processor $payment_processor */ |
201 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
201 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
202 | 202 | // set revisit flag for payment processor |
203 | - $payment_processor->set_revisit( false ); |
|
203 | + $payment_processor->set_revisit(false); |
|
204 | 204 | // load EEM_Transaction |
205 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
206 | - foreach ( self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID ) { |
|
205 | + EE_Registry::instance()->load_model('Transaction'); |
|
206 | + foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
207 | 207 | // reschedule the cron if we can't hit the db right now |
208 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
208 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
209 | 209 | // reset cron job for updating the TXN |
210 | 210 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
211 | 211 | time() + EE_Cron_Tasks::reschedule_timeout, |
@@ -214,14 +214,14 @@ discard block |
||
214 | 214 | ); |
215 | 215 | continue; |
216 | 216 | } |
217 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
218 | - $payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID ); |
|
217 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
218 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
219 | 219 | // verify transaction |
220 | - if ( $transaction instanceof EE_Transaction && $payment instanceof EE_Payment ) { |
|
220 | + if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
221 | 221 | // now try to update the TXN with any payments |
222 | - $payment_processor->update_txn_based_on_payment( $transaction, $payment, true, true ); |
|
222 | + $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
223 | 223 | } |
224 | - unset( self::$_update_transactions_with_payment[ $TXN_ID ] ); |
|
224 | + unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | } |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | $TXN_ID |
259 | 259 | ) { |
260 | 260 | // validate $TXN_ID and $timestamp |
261 | - $TXN_ID = absint( $TXN_ID ); |
|
262 | - $timestamp = absint( $timestamp ); |
|
263 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
264 | - if ( $TXN_ID && $timestamp ) { |
|
261 | + $TXN_ID = absint($TXN_ID); |
|
262 | + $timestamp = absint($timestamp); |
|
263 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
264 | + if ($TXN_ID && $timestamp) { |
|
265 | 265 | wp_schedule_single_event( |
266 | 266 | $timestamp, |
267 | 267 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
268 | - array( $TXN_ID ) |
|
268 | + array($TXN_ID) |
|
269 | 269 | ); |
270 | 270 | } |
271 | 271 | } |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @param int $TXN_ID |
289 | 289 | */ |
290 | - public static function check_for_abandoned_transactions( $TXN_ID = 0 ) { |
|
291 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
292 | - if ( absint( $TXN_ID )) { |
|
293 | - self::$_abandoned_transactions[] = $TXN_ID; |
|
290 | + public static function check_for_abandoned_transactions($TXN_ID = 0) { |
|
291 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
292 | + if (absint($TXN_ID)) { |
|
293 | + self::$_abandoned_transactions[] = $TXN_ID; |
|
294 | 294 | add_action( |
295 | 295 | 'shutdown', |
296 | - array( 'EE_Cron_Tasks', 'finalize_abandoned_transactions' ), |
|
296 | + array('EE_Cron_Tasks', 'finalize_abandoned_transactions'), |
|
297 | 297 | 5 |
298 | 298 | ); |
299 | 299 | } |
@@ -312,21 +312,21 @@ discard block |
||
312 | 312 | * @throws \EE_Error |
313 | 313 | */ |
314 | 314 | public static function finalize_abandoned_transactions() { |
315 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
315 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
316 | 316 | // are there any TXNs that need cleaning up ? |
317 | - if ( ! empty( self::$_abandoned_transactions ) ) { |
|
317 | + if ( ! empty(self::$_abandoned_transactions)) { |
|
318 | 318 | /** @type EE_Transaction_Processor $transaction_processor */ |
319 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
319 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
320 | 320 | // set revisit flag for txn processor |
321 | - $transaction_processor->set_revisit( false ); |
|
321 | + $transaction_processor->set_revisit(false); |
|
322 | 322 | /** @type EE_Payment_Processor $payment_processor */ |
323 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
323 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
324 | 324 | // load EEM_Transaction |
325 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
326 | - foreach ( self::$_abandoned_transactions as $TXN_ID ) { |
|
327 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
325 | + EE_Registry::instance()->load_model('Transaction'); |
|
326 | + foreach (self::$_abandoned_transactions as $TXN_ID) { |
|
327 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
328 | 328 | // reschedule the cron if we can't hit the db right now |
329 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
329 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
330 | 330 | // reset cron job for finalizing the TXN |
331 | 331 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
332 | 332 | time() + EE_Cron_Tasks::reschedule_timeout, |
@@ -334,17 +334,17 @@ discard block |
||
334 | 334 | ); |
335 | 335 | continue; |
336 | 336 | } |
337 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
337 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
338 | 338 | // verify transaction |
339 | - if ( $transaction instanceof EE_Transaction ) { |
|
339 | + if ($transaction instanceof EE_Transaction) { |
|
340 | 340 | // don't finalize the TXN if it has already been completed |
341 | - if ( $transaction->all_reg_steps_completed() === true ) { |
|
341 | + if ($transaction->all_reg_steps_completed() === true) { |
|
342 | 342 | continue; |
343 | 343 | } |
344 | 344 | // let's simulate an IPN here which will trigger any notifications that need to go out |
345 | - $payment_processor->update_txn_based_on_payment( $transaction, $transaction->last_payment(), true, true ); |
|
345 | + $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, true); |
|
346 | 346 | } |
347 | - unset( self::$_abandoned_transactions[ $TXN_ID ] ); |
|
347 | + unset(self::$_abandoned_transactions[$TXN_ID]); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | //when a transaction is initially made, schedule this check. |
361 | 361 | //if it has NO REG data by the time it has expired, forget about it |
362 | 362 | public static function clean_out_junk_transactions() { |
363 | - if( EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
363 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
364 | 364 | EEM_Transaction::instance('')->delete_junk_transactions(); |
365 | 365 | EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
366 | 366 | EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
69 | 69 | * @access public |
70 | 70 | */ |
71 | - public function __construct( $routing = TRUE ) { |
|
72 | - require_once( EE_MODELS . 'EEM_Question.model.php' ); |
|
73 | - require_once( EE_MODELS . 'EEM_Question_Group.model.php' ); |
|
74 | - $this->_question_model= EEM_Question::instance(); |
|
75 | - $this->_question_group_model=EEM_Question_Group::instance(); |
|
76 | - parent::__construct( $routing ); |
|
71 | + public function __construct($routing = TRUE) { |
|
72 | + require_once(EE_MODELS.'EEM_Question.model.php'); |
|
73 | + require_once(EE_MODELS.'EEM_Question_Group.model.php'); |
|
74 | + $this->_question_model = EEM_Question::instance(); |
|
75 | + $this->_question_group_model = EEM_Question_Group::instance(); |
|
76 | + parent::__construct($routing); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | *_set_page_routes |
110 | 110 | */ |
111 | 111 | protected function _set_page_routes() { |
112 | - $qst_id = ! empty( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0; |
|
112 | + $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
113 | 113 | $this->_page_routes = array( |
114 | 114 | 'default' => array( |
115 | 115 | 'func' => '_questions_overview_list_table', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | 'update_question' => array( |
132 | 132 | 'func' => '_insert_or_update_question', |
133 | - 'args' => array('new_question' => FALSE ), |
|
133 | + 'args' => array('new_question' => FALSE), |
|
134 | 134 | 'capability' => 'ee_edit_question', |
135 | 135 | 'obj_id' => $qst_id, |
136 | 136 | 'noheader' => TRUE, |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | 'filename' => 'registration_form_questions_overview_views_bulk_actions_search' |
166 | 166 | ) |
167 | 167 | ), |
168 | - 'help_tour' => array( 'Registration_Form_Questions_Overview_Help_Tour'), |
|
168 | + 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
169 | 169 | 'require_nonce' => FALSE, |
170 | 170 | 'qtips' => array( |
171 | 171 | 'EE_Registration_Form_Tips' |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'filename' => 'registration_form_question_groups' |
185 | 185 | ), |
186 | 186 | ), |
187 | - 'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'), |
|
187 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
188 | 188 | 'require_nonce' => FALSE |
189 | 189 | ), |
190 | 190 | |
@@ -193,16 +193,16 @@ discard block |
||
193 | 193 | 'label' => esc_html__('Edit Question', 'event_espresso'), |
194 | 194 | 'order' => 15, |
195 | 195 | 'persistent' => FALSE, |
196 | - 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
196 | + 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), $this->_current_page_view_url) : $this->_admin_base_url |
|
197 | 197 | ), |
198 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
198 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
199 | 199 | 'help_tabs' => array( |
200 | 200 | 'registration_form_edit_question_group_help_tab' => array( |
201 | 201 | 'title' => esc_html__('Edit Question', 'event_espresso'), |
202 | 202 | 'filename' => 'registration_form_edit_question' |
203 | 203 | ), |
204 | 204 | ), |
205 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
205 | + 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
206 | 206 | 'require_nonce' => FALSE |
207 | 207 | ), |
208 | 208 | ); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | //none of the below group are currently used for Event Categories |
231 | 231 | protected function _add_feature_pointers() {} |
232 | 232 | public function load_scripts_styles() { |
233 | - wp_register_style( 'espresso_registration', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
233 | + wp_register_style('espresso_registration', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
234 | 234 | wp_enqueue_style('espresso_registration'); |
235 | 235 | } |
236 | 236 | public function admin_init() {} |
@@ -246,20 +246,20 @@ discard block |
||
246 | 246 | |
247 | 247 | public function load_scripts_styles_add_question() { |
248 | 248 | $this->load_scripts_styles_forms(); |
249 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
250 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
249 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
250 | + wp_enqueue_script('espresso_registration_form_single'); |
|
251 | 251 | } |
252 | 252 | public function load_scripts_styles_edit_question() { |
253 | 253 | $this->load_scripts_styles_forms(); |
254 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
255 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
254 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
255 | + wp_enqueue_script('espresso_registration_form_single'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
259 | 259 | |
260 | 260 | |
261 | 261 | public function recaptcha_info_help_tab() { |
262 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
262 | + $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php'; |
|
263 | 263 | EEH_Template::display_template($template, array()); |
264 | 264 | } |
265 | 265 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ) |
292 | 292 | ); |
293 | 293 | |
294 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) { |
|
294 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) { |
|
295 | 295 | $this->_views['trash'] = array( |
296 | 296 | 'slug' => 'trash', |
297 | 297 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | */ |
310 | 310 | protected function _questions_groups_preview() { |
311 | 311 | $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
312 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__( 'Preview Question Groups Overview List Table screenshot', 'event_espresso' ) . '" />'; |
|
313 | - $this->_template_args['preview_text'] = '<strong>'.esc_html__( 'Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso' ).'</strong>'; |
|
314 | - $this->display_admin_caf_preview_page( 'question_groups_tab' ); |
|
312 | + $this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', 'event_espresso').'" />'; |
|
313 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__('Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso').'</strong>'; |
|
314 | + $this->display_admin_caf_preview_page('question_groups_tab'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -322,58 +322,58 @@ discard block |
||
322 | 322 | * @param \EEM_Base $model |
323 | 323 | * @return array where each key is the name of a model's field/db column, and each value is its value. |
324 | 324 | */ |
325 | - protected function _set_column_values_for(EEM_Base $model){ |
|
326 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
327 | - $set_column_values=array(); |
|
325 | + protected function _set_column_values_for(EEM_Base $model) { |
|
326 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
327 | + $set_column_values = array(); |
|
328 | 328 | |
329 | 329 | //some initial checks for proper values. |
330 | 330 | //if QST_admin_only, then no matter what QST_required is we disable. |
331 | - if ( !empty( $this->_req_data['QST_admin_only'] ) ) { |
|
331 | + if ( ! empty($this->_req_data['QST_admin_only'])) { |
|
332 | 332 | $this->_req_data['QST_required'] = 0; |
333 | 333 | } |
334 | - foreach($model->field_settings() as $fieldName=>$settings){ |
|
334 | + foreach ($model->field_settings() as $fieldName=>$settings) { |
|
335 | 335 | // basically if QSG_identifier is empty or not set |
336 | - if ( $fieldName === 'QSG_identifier' && ( isset( $this->_req_data['QSG_identifier'] ) && empty( $this->_req_data['QSG_identifier'] ) )) { |
|
337 | - $QSG_name = isset( $this->_req_data['QSG_name'] ) ? $this->_req_data['QSG_name'] : '' ; |
|
338 | - $set_column_values[$fieldName] = sanitize_title($QSG_name ) . '-' . uniqid( '', true ); |
|
336 | + if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
337 | + $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
338 | + $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid('', true); |
|
339 | 339 | // dd($set_column_values); |
340 | 340 | } |
341 | 341 | //if the admin label is blank, use a slug version of the question text |
342 | - else if ( $fieldName === 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] ) )) { |
|
343 | - $QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ; |
|
344 | - $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10)); |
|
342 | + else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
343 | + $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
344 | + $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
348 | - else if ( $fieldName === 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
348 | + else if ($fieldName === 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) { |
|
349 | 349 | $set_column_values[$fieldName] = 0; |
350 | 350 | } |
351 | 351 | |
352 | - else if ( $fieldName === 'QST_max' ) { |
|
352 | + else if ($fieldName === 'QST_max') { |
|
353 | 353 | $qst_system = EEM_Question::instance()->get_var( |
354 | 354 | array( |
355 | 355 | array( |
356 | - 'QST_ID' => isset( $this->_req_data[ 'QST_ID' ] ) ? $this->_req_data[ 'QST_ID' ] : 0 |
|
356 | + 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0 |
|
357 | 357 | ) |
358 | 358 | ), |
359 | 359 | 'QST_system' ); |
360 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question( $qst_system ); |
|
361 | - if( empty( $this->_req_data[ 'QST_max' ] ) || |
|
362 | - $this->_req_data[ 'QST_max' ] > $max_max ) { |
|
363 | - $set_column_values[ $fieldName ] = $max_max; |
|
360 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
361 | + if (empty($this->_req_data['QST_max']) || |
|
362 | + $this->_req_data['QST_max'] > $max_max) { |
|
363 | + $set_column_values[$fieldName] = $max_max; |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | 368 | //only add a property to the array if it's not null (otherwise the model should just use the default value) |
369 | - if( |
|
370 | - ! isset( $set_column_values[ $fieldName ] ) && |
|
371 | - isset($this->_req_data[$fieldName] ) ){ |
|
372 | - $set_column_values[$fieldName]=$this->_req_data[$fieldName]; |
|
369 | + if ( |
|
370 | + ! isset($set_column_values[$fieldName]) && |
|
371 | + isset($this->_req_data[$fieldName]) ) { |
|
372 | + $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
376 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
376 | + return $set_column_values; //validation fo this data to be performed by the model before insertion. |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -392,39 +392,39 @@ discard block |
||
392 | 392 | * _edit_question |
393 | 393 | */ |
394 | 394 | protected function _edit_question() { |
395 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
396 | - $ID=isset( $this->_req_data['QST_ID'] ) && ! empty( $this->_req_data['QST_ID'] ) ? absint( $this->_req_data['QST_ID'] ) : FALSE; |
|
395 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
396 | + $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE; |
|
397 | 397 | |
398 | - switch( $this->_req_action ) { |
|
398 | + switch ($this->_req_action) { |
|
399 | 399 | case 'add_question' : |
400 | - $this->_admin_page_title = esc_html__( 'Add Question', 'event_espresso' ); |
|
400 | + $this->_admin_page_title = esc_html__('Add Question', 'event_espresso'); |
|
401 | 401 | break; |
402 | 402 | case 'edit_question' : |
403 | - $this->_admin_page_title = esc_html__( 'Edit Question', 'event_espresso' ); |
|
403 | + $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso'); |
|
404 | 404 | break; |
405 | 405 | default : |
406 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
406 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | // add PRC_ID to title if editing |
410 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
411 | - if($ID){ |
|
412 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
413 | - $additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
410 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
411 | + if ($ID) { |
|
412 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
413 | + $additional_hidden_fields = array('QST_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
414 | 414 | $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
415 | - }else{ |
|
416 | - $question= EE_Question::new_instance(); |
|
415 | + } else { |
|
416 | + $question = EE_Question::new_instance(); |
|
417 | 417 | $question->set_order_to_latest(); |
418 | 418 | $this->_set_add_edit_form_tags('insert_question'); |
419 | 419 | } |
420 | - $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category( $question->type() ) : $this->_question_model->allowed_question_types(); |
|
421 | - $this->_template_args['QST_ID']=$ID; |
|
422 | - $this->_template_args['question']=$question; |
|
423 | - $this->_template_args['question_types']= $question_types; |
|
424 | - $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() ); |
|
420 | + $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
421 | + $this->_template_args['QST_ID'] = $ID; |
|
422 | + $this->_template_args['question'] = $question; |
|
423 | + $this->_template_args['question_types'] = $question_types; |
|
424 | + $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID()); |
|
425 | 425 | $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
426 | - $this->_set_publish_post_box_vars( 'id', $ID ); |
|
427 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
426 | + $this->_set_publish_post_box_vars('id', $ID); |
|
427 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', $this->_template_args, TRUE); |
|
428 | 428 | |
429 | 429 | // the details template wrapper |
430 | 430 | $this->display_admin_page_with_sidebar(); |
@@ -439,18 +439,18 @@ discard block |
||
439 | 439 | EE_Registry::instance()->load_helper('HTML'); |
440 | 440 | $descriptions = ''; |
441 | 441 | $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
442 | - foreach ( $question_type_descriptions as $type => $question_type_description ) { |
|
443 | - if ( $type == 'HTML_TEXTAREA' ) { |
|
442 | + foreach ($question_type_descriptions as $type => $question_type_description) { |
|
443 | + if ($type == 'HTML_TEXTAREA') { |
|
444 | 444 | $html = new EE_Simple_HTML_Validation_Strategy(); |
445 | 445 | $question_type_description .= sprintf( |
446 | - esc_html__( '%1$s(allowed tags: %2$s)', 'event_espresso' ), |
|
446 | + esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
447 | 447 | '<br/>', |
448 | 448 | $html->get_list_of_allowed_tags() |
449 | 449 | ); |
450 | 450 | } |
451 | 451 | $descriptions .= EEH_HTML::p( |
452 | 452 | $question_type_description, |
453 | - 'question_type_description-' . $type, |
|
453 | + 'question_type_description-'.$type, |
|
454 | 454 | 'question_type_description description', |
455 | 455 | 'display:none;' |
456 | 456 | ); |
@@ -464,58 +464,58 @@ discard block |
||
464 | 464 | * @param bool|true $new_question |
465 | 465 | * @throws \EE_Error |
466 | 466 | */ |
467 | - protected function _insert_or_update_question( $new_question = TRUE) { |
|
468 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
469 | - $set_column_values=$this->_set_column_values_for($this->_question_model); |
|
470 | - if($new_question){ |
|
471 | - $ID=$this->_question_model->insert($set_column_values); |
|
467 | + protected function _insert_or_update_question($new_question = TRUE) { |
|
468 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
469 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
470 | + if ($new_question) { |
|
471 | + $ID = $this->_question_model->insert($set_column_values); |
|
472 | 472 | $success = $ID ? true : false; |
473 | 473 | $action_desc = 'added'; |
474 | - }else{ |
|
475 | - $ID=absint($this->_req_data['QST_ID']); |
|
476 | - $pk=$this->_question_model->primary_key_name(); |
|
477 | - $wheres=array($pk=>$ID); |
|
474 | + } else { |
|
475 | + $ID = absint($this->_req_data['QST_ID']); |
|
476 | + $pk = $this->_question_model->primary_key_name(); |
|
477 | + $wheres = array($pk=>$ID); |
|
478 | 478 | unset($set_column_values[$pk]); |
479 | - $success= $this->_question_model->update($set_column_values,array($wheres)); |
|
480 | - $action_desc='updated'; |
|
479 | + $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
480 | + $action_desc = 'updated'; |
|
481 | 481 | } |
482 | 482 | |
483 | - if ($ID){ |
|
483 | + if ($ID) { |
|
484 | 484 | //save the related options |
485 | 485 | //trash removed options, save old ones |
486 | 486 | //get list of all options |
487 | 487 | /** @type EE_Question $question */ |
488 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
489 | - $options=$question->options(); |
|
490 | - if(! empty($options)){ |
|
491 | - foreach($options as $option_ID=>$option){ |
|
492 | - $option_req_index=$this->_get_option_req_data_index($option_ID); |
|
493 | - if($option_req_index!==FALSE){ |
|
488 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
489 | + $options = $question->options(); |
|
490 | + if ( ! empty($options)) { |
|
491 | + foreach ($options as $option_ID=>$option) { |
|
492 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
493 | + if ($option_req_index !== FALSE) { |
|
494 | 494 | $option->save($this->_req_data['question_options'][$option_req_index]); |
495 | - }else{ |
|
495 | + } else { |
|
496 | 496 | //not found, remove it |
497 | 497 | $option->delete(); |
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
501 | 501 | //save new related options |
502 | - foreach($this->_req_data['question_options'] as $index=>$option_req_data){ |
|
503 | - if( empty($option_req_data['QSO_ID'] ) && ( ( isset( $option_req_data['QSO_value'] ) && $option_req_data['QSO_value'] !== '' ) || ! empty( $option_req_data['QSO_desc'] ) ) ) {//no ID! save it! |
|
504 | - if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === '' ){ |
|
505 | - $option_req_data['QSO_value']=$option_req_data['QSO_desc']; |
|
502 | + foreach ($this->_req_data['question_options'] as $index=>$option_req_data) { |
|
503 | + if (empty($option_req_data['QSO_ID']) && ((isset($option_req_data['QSO_value']) && $option_req_data['QSO_value'] !== '') || ! empty($option_req_data['QSO_desc']))) {//no ID! save it! |
|
504 | + if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') { |
|
505 | + $option_req_data['QSO_value'] = $option_req_data['QSO_desc']; |
|
506 | 506 | } |
507 | - $new_option=EE_Question_Option::new_instance( array( 'QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
507 | + $new_option = EE_Question_Option::new_instance(array('QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
508 | 508 | $new_option->save(); |
509 | 509 | } |
510 | 510 | } |
511 | 511 | } |
512 | - $query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID ); |
|
513 | - if ( $success !== FALSE ) { |
|
514 | - $msg = $new_question ? sprintf( esc_html__('The %s has been created', 'event_espresso'), $this->_question_model->item_name() ) : sprintf( esc_html__('The %s has been updated', 'event_espresso' ), $this->_question_model->item_name() ); |
|
515 | - EE_Error::add_success( $msg ); |
|
512 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
513 | + if ($success !== FALSE) { |
|
514 | + $msg = $new_question ? sprintf(esc_html__('The %s has been created', 'event_espresso'), $this->_question_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), $this->_question_model->item_name()); |
|
515 | + EE_Error::add_success($msg); |
|
516 | 516 | } |
517 | 517 | |
518 | - $this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE); |
|
518 | + $this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | * @param int $ID of the question option to find |
529 | 529 | * @return int index in question_options array if successful, FALSE if unsuccessful |
530 | 530 | */ |
531 | - protected function _get_option_req_data_index($ID){ |
|
532 | - $req_data_for_question_options=$this->_req_data['question_options']; |
|
533 | - foreach($req_data_for_question_options as $num=>$option_data){ |
|
534 | - if( array_key_exists('QSO_ID',$option_data) && (int)$option_data['QSO_ID'] === $ID ){ |
|
531 | + protected function _get_option_req_data_index($ID) { |
|
532 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
533 | + foreach ($req_data_for_question_options as $num=>$option_data) { |
|
534 | + if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) { |
|
535 | 535 | return $num; |
536 | 536 | } |
537 | 537 | } |
@@ -553,25 +553,25 @@ discard block |
||
553 | 553 | * @param int $current_page |
554 | 554 | * @return array lik EEM_Base::get_all's $query_params parameter |
555 | 555 | */ |
556 | - protected function get_query_params($model, $per_page=10,$current_page=10){ |
|
556 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) { |
|
557 | 557 | $query_params = array(); |
558 | - $offset=($current_page-1)*$per_page; |
|
559 | - $query_params['limit']=array($offset,$per_page); |
|
560 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
558 | + $offset = ($current_page - 1) * $per_page; |
|
559 | + $query_params['limit'] = array($offset, $per_page); |
|
560 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
561 | 561 | $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
562 | 562 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
563 | - $query_params['order_by']=array( $field_to_order_by => $order ); |
|
564 | - $search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null; |
|
565 | - if(! empty($search_string)){ |
|
566 | - if($model instanceof EEM_Question_Group){ |
|
567 | - $query_params[0]=array( |
|
563 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
564 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
565 | + if ( ! empty($search_string)) { |
|
566 | + if ($model instanceof EEM_Question_Group) { |
|
567 | + $query_params[0] = array( |
|
568 | 568 | 'OR'=>array( |
569 | - 'QSG_name'=>array('LIKE',"%$search_string%"), |
|
570 | - 'QSG_desc'=>array('LIKE',"%$search_string%")) |
|
569 | + 'QSG_name'=>array('LIKE', "%$search_string%"), |
|
570 | + 'QSG_desc'=>array('LIKE', "%$search_string%")) |
|
571 | 571 | ); |
572 | - }else{ |
|
573 | - $query_params[0]=array( |
|
574 | - 'QST_display_text'=>array('LIKE',"%$search_string%") |
|
572 | + } else { |
|
573 | + $query_params[0] = array( |
|
574 | + 'QST_display_text'=>array('LIKE', "%$search_string%") |
|
575 | 575 | ); |
576 | 576 | } |
577 | 577 | } |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | * @param bool|false $count |
620 | 620 | * @return \EE_Soft_Delete_Base_Class[]|int |
621 | 621 | */ |
622 | - public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) { |
|
622 | + public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) { |
|
623 | 623 | $QST = EEM_Question::instance(); |
624 | 624 | $query_params = $this->get_query_params($QST, $per_page, $current_page); |
625 | - if ($count){ |
|
626 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
625 | + if ($count) { |
|
626 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
627 | 627 | $results = $QST->count($where); |
628 | - }else{ |
|
628 | + } else { |
|
629 | 629 | $results = $QST->get_all($query_params); |
630 | 630 | } |
631 | 631 | return $results; |
@@ -640,10 +640,10 @@ discard block |
||
640 | 640 | * @param bool|false $count |
641 | 641 | * @return \EE_Soft_Delete_Base_Class[]|int |
642 | 642 | */ |
643 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
644 | - $query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page); |
|
645 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
646 | - $questions =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
643 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
644 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
645 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
646 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
647 | 647 | return $questions; |
648 | 648 | } |
649 | 649 | |
@@ -655,12 +655,12 @@ discard block |
||
655 | 655 | * @param bool|false $count |
656 | 656 | * @return \EE_Soft_Delete_Base_Class[] |
657 | 657 | */ |
658 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
658 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
659 | 659 | /** @type EEM_Question_Group $questionGroupModel */ |
660 | 660 | $questionGroupModel = EEM_Question_Group::instance(); |
661 | 661 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
662 | 662 | return $questionGroupModel->get_all( |
663 | - $this->get_query_params( $questionGroupModel, $per_page, $current_page ) |
|
663 | + $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
664 | 664 | ); |
665 | 665 | } |
666 | 666 |
@@ -1,36 +1,36 @@ |
||
1 | 1 | |
2 | 2 | <h4 id="reg-page-totals-hdr" class=""> |
3 | - <span class="drk-grey-text"><?php _e('Registrations:', 'event_espresso'); ?></span> <?php echo $reg_count;?> |
|
3 | + <span class="drk-grey-text"><?php _e('Registrations:', 'event_espresso'); ?></span> <?php echo $reg_count; ?> |
|
4 | 4 | </h4> |
5 | 5 | |
6 | 6 | <div class="spco-payment-info-dv"> |
7 | 7 | <table id="spco-payment-info-table"> |
8 | 8 | <thead> |
9 | 9 | <tr> |
10 | - <th scope="col" width=""><?php _e('Name and Description', 'event_espresso');?></th> |
|
11 | - <th scope="col" width="15%" class="jst-cntr"><?php _e('Price', 'event_espresso');?></th> |
|
12 | - <th scope="col" width="5%" class="jst-cntr"><?php _e( 'Qty', 'event_espresso' ); ?></th> |
|
13 | - <th scope="col" width="15%" class="jst-cntr"><?php _e('Total', 'event_espresso');?></th> |
|
14 | - <?php do_action( 'AHEE__registration_page_payment_options__payment_info_table_thead_row_end' ); ?> |
|
10 | + <th scope="col" width=""><?php _e('Name and Description', 'event_espresso'); ?></th> |
|
11 | + <th scope="col" width="15%" class="jst-cntr"><?php _e('Price', 'event_espresso'); ?></th> |
|
12 | + <th scope="col" width="5%" class="jst-cntr"><?php _e('Qty', 'event_espresso'); ?></th> |
|
13 | + <th scope="col" width="15%" class="jst-cntr"><?php _e('Total', 'event_espresso'); ?></th> |
|
14 | + <?php do_action('AHEE__registration_page_payment_options__payment_info_table_thead_row_end'); ?> |
|
15 | 15 | </tr> |
16 | 16 | </thead> |
17 | 17 | <tbody> |
18 | - <?php echo $transaction_details;?> |
|
19 | - <?php do_action( 'AHEE__registration_page_payment_options__payment_info_table_tbody_end' ); ?> |
|
18 | + <?php echo $transaction_details; ?> |
|
19 | + <?php do_action('AHEE__registration_page_payment_options__payment_info_table_tbody_end'); ?> |
|
20 | 20 | </tbody> |
21 | 21 | </table> |
22 | 22 | </div> |
23 | 23 | <div class="clear-float"> </div> |
24 | 24 | |
25 | - <?php echo $before_payment_options; ?> |
|
25 | + <?php echo $before_payment_options; ?> |
|
26 | 26 | |
27 | 27 | <div id="methods-of-payment"> |
28 | 28 | <?php echo $payment_options; ?> |
29 | 29 | </div> |
30 | 30 | <!-- end #methods-of-payment --> |
31 | 31 | |
32 | - <?php echo $after_payment_options; ?> |
|
32 | + <?php echo $after_payment_options; ?> |
|
33 | 33 | |
34 | - <?php echo $default_hidden_inputs; ?> |
|
35 | - <?php echo $extra_hidden_inputs; ?> |
|
34 | + <?php echo $default_hidden_inputs; ?> |
|
35 | + <?php echo $extra_hidden_inputs; ?> |
|
36 | 36 |