protected function _country_settings()
 {
     $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
     $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
     //load field generator helper
     $this->_template_args['values'] = $this->_yes_no_values;
     $this->_template_args['countries'] = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_ID' => 0, 'QST_display_text' => __('Select Country', 'event_espresso'), 'QST_system' => 'admin-country')), EE_Answer::new_instance(array('ANS_ID' => 0, 'ANS_value' => $CNT_ISO)), array('input_id' => 'country', 'input_name' => 'country', 'input_prefix' => '', 'append_qstn_id' => FALSE));
     //		EEH_Debug_Tools::printr( $this->_template_args['countries'], 'countries  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
     add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
     $this->_template_args['country_details_settings'] = $this->display_country_settings();
     $this->_template_args['country_states_settings'] = $this->display_country_states();
     $this->_set_add_edit_form_tags('update_country_settings');
     $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
     $this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', $this->_template_args, TRUE);
     $this->display_admin_page_with_no_sidebar();
 }
 public function venue_address_metabox()
 {
     $template_args['_venue'] = $this->_cpt_model_obj;
     $template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input($QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => 'State', 'QST_system' => 'state')), EE_Answer::new_instance(array('ANS_value' => $this->_cpt_model_obj->state_ID())), array('input_name' => 'sta_id', 'input_id' => 'sta_id', 'input_class' => '', 'input_prefix' => '', 'append_qstn_id' => FALSE)));
     $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input($QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => 'Country', 'QST_system' => 'country')), EE_Answer::new_instance(array('ANS_value' => $this->_cpt_model_obj->country_ID())), array('input_name' => 'cnt_iso', 'input_id' => 'cnt_iso', 'input_class' => '', 'input_prefix' => '', 'append_qstn_id' => FALSE)));
     $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
     EEH_Template::display_template($template, $template_args);
 }
 /**
  * Metabox for person details
  * @param  WP_Post $post wp post object
  * @return string        person address details (and form)
  */
 public function person_address_details($post)
 {
     //get people object (should already have it)
     $this->_template_args['person'] = $this->_cpt_model_obj;
     $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array('QST_ID' => 0, 'QST_display_text' => __('State/Province', 'event_espresso'), 'QST_system' => 'admin-state')), EE_Answer::new_instance(array('ANS_ID' => 0, 'ANS_value' => $this->_cpt_model_obj->state_ID())), array('input_id' => 'STA_ID', 'input_name' => 'STA_ID', 'input_prefix' => '', 'append_qstn_id' => FALSE)));
     $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array('QST_ID' => 0, 'QST_display_text' => __('Country', 'event_espresso'), 'QST_system' => 'admin-country')), EE_Answer::new_instance(array('ANS_ID' => 0, 'ANS_value' => $this->_cpt_model_obj->country_ID())), array('input_id' => 'CNT_ISO', 'input_name' => 'CNT_ISO', 'input_prefix' => '', 'append_qstn_id' => FALSE)));
     $template = EEA_PEOPLE_ADDON_ADMIN_TEMPLATE_PATH . 'people_address_details_metabox_content.template.php';
     EEH_Template::display_template($template, $this->_template_args);
 }
 /**
  * generate_question_groups_html
  *
  * @param array         $question_groups
  * @param array        $q_meta
  * @param bool         $from_admin
  * @param string       $group_wrapper
  * @return string HTML
  */
 static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset')
 {
     $html = '';
     $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
     $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
     $default_q_meta = array('att_nmbr' => 1, 'ticket_id' => '', 'input_name' => '', 'input_id' => '', 'input_class' => '');
     $q_meta = array_merge($default_q_meta, $q_meta);
     //EEH_Debug_Tools::printr( $q_meta, '$q_meta  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     if (!empty($question_groups)) {
         //			EEH_Debug_Tools::printr( $question_groups, '$question_groups  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
         // loop thru question groups
         foreach ($question_groups as $QSG) {
             if ($QSG instanceof EE_Question_Group) {
                 // check that questions exist
                 $where = array('QST_deleted' => 0);
                 if (!$from_admin) {
                     $where['QST_admin_only'] = 0;
                 }
                 $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC')));
                 if (!empty($questions)) {
                     // use fieldsets
                     $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get('QSG_identifier') . '">';
                     // group_name
                     if ($QSG->show_group_name()) {
                         $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty('QSG_name') . '</h5>';
                     }
                     // group_desc
                     if ($QSG->show_group_desc()) {
                         $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty('QSG_desc') . '</div>';
                     }
                     $html .= $before_question_group_questions;
                     // loop thru questions
                     foreach ($questions as $QST) {
                         $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID();
                         $answer = NULL;
                         if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
                             // check for answer in $_GET in case we are reprocessing a form after an error
                             if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) {
                                 $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]);
                             }
                         } else {
                             if (isset($q_meta['attendee']) && $q_meta['attendee']) {
                                 //attendee data from the session
                                 $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL;
                             }
                         }
                         $QFI = new EE_Question_Form_Input($QST, EE_Answer::new_instance(array('ANS_ID' => 0, 'QST_ID' => 0, 'REG_ID' => 0, 'ANS_value' => $answer)), $q_meta);
                         //EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                         $html .= self::generate_form_input($QFI);
                     }
                     $html .= $after_question_group_questions;
                     $html .= "\n\t" . '</' . $group_wrapper . '>';
                 }
             }
         }
     }
     return $html;
 }
 /**
  * @access public
  * @param EE_Registration $registration
  * @param EE_Question     $question
  * @return 	EE_Form_Input_Base
  */
 public function reg_form_question(EE_Registration $registration, EE_Question $question)
 {
     // if this question was for an attendee detail, then check for that answer
     $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value($registration, $question->ID());
     $answer = $answer_value === null ? EEM_Answer::instance()->get_one(array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))) : null;
     // if NOT returning to edit an existing registration OR if this question is for an attendee property OR we still don't have an EE_Answer object
     if (!$registration->reg_url_link() || $answer_value || !$answer instanceof EE_Answer) {
         // create an EE_Answer object for storing everything in
         $answer = EE_Answer::new_instance(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()));
     }
     // verify instance
     if ($answer instanceof EE_Answer) {
         if (!empty($answer_value)) {
             $answer->set('ANS_value', $answer_value);
         }
         $answer->cache('Question', $question);
         $answer_cache_id = $question->system_ID() != NULL ? $question->system_ID() . '-' . $registration->reg_url_link() : $question->ID() . '-' . $registration->reg_url_link();
         $registration->cache('Answer', $answer, $answer_cache_id);
     }
     return $this->_generate_question_input($registration, $question, $answer);
 }
 /**
  * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id.  This will be used in our dummy data setup
  * @return array
  */
 private function _get_some_q_and_as()
 {
     $quests_array = array(0 => array(555, __('What is your favorite planet?', 'event_espresso'), 0), 1 => array(556, __('What is your favorite food?', 'event_espresso'), 0), 2 => array(557, __('How many lightyears have you travelled', 'event_espresso'), 0));
     $ans_array = array(0 => array(999, 555, 'Tattoine'), 1 => array(1000, 555, 'Alderaan'), 2 => array(1001, 555, 'Dantooine'), 3 => array(1002, 556, 'Fish Fingers'), 4 => array(1003, 556, 'Sushi'), 5 => array(1004, 556, 'Water'), 6 => array(1005, 557, 'A lot'), 7 => array(1006, 557, "That's none of your business."), 8 => array(1007, 557, "People less travel me then."));
     $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system');
     $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value');
     EE_Registry::instance()->load_class('Question', array(), FALSE, TRUE, TRUE);
     EE_Registry::instance()->load_class('Answer', array(), FALSE, TRUE, TRUE);
     //first the questions
     foreach ($quests_array as $qst) {
         $qstobj = array_combine($qst_columns, $qst);
         $qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj);
     }
     //now the answers (and we'll setup our arrays)
     $q_n_as = array();
     foreach ($ans_array as $ans) {
         $ansobj = array_combine($ans_columns, $ans);
         $ansobj = EE_Answer::new_instance($ansobj);
         $q_n_as['answers'][$ansobj->ID()] = $ansobj;
         $q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')];
     }
     return $q_n_as;
 }
 /**
  * 	display_add_new_state_micro_form
  *
  * 	@access 	public
  * 	@return 		string
  */
 public static function display_add_new_state_micro_form($input_html, $question, $answer, $name, $id, $class, $system_ID)
 {
     // load JS
     add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
     $output = '';
     // we're only doing this for state select inputs
     if ($system_ID == 'state') {
         // add hidden input to indicate that a new state is being added
         $output .= EEH_Form_Fields::hidden_input(str_replace('state', 'add_new_state', $name), 0, str_replace('state', 'add_new_state', $id));
         $output .= '<a id="display-' . $id . '" class="ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js" rel="' . $id . '">' . __('click here to add a new state/province', 'event_espresso') . '</a>';
         $output .= '<div id="' . $id . '-dv" class="ee-form-add-new-state-dv" style="display: none;">';
         $output .= '<h6>' . __('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso') . '</h6>';
         $output .= '<ul>';
         $output .= sprintf(__('%1$sfirst select the Country that your State/Province belongs to%2$s%1$senter the name of your State/Province%2$s%1$senter a two to six letter abbreviation for the name of your State/Province%2$s%1$sclick the ADD button%2$s', 'event_espresso'), '<li>', '</li>');
         $output .= '</ul>';
         // NEW STATE COUNTRY
         $cntry_id = str_replace('state', 'new_state_country', $id);
         $cntry_input = str_replace('state', 'new_state_country', $name);
         $country = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => __('New State/Province Country', 'event_espresso'), 'QST_system' => 'admin-country', 'QST_type' => EEM_Question::QST_type_dropdown, 'QST_required' => FALSE)), EE_Answer::new_instance(array('ANS_value' => EE_Registry::instance()->REQ->is_set($cntry_input) ? EE_Registry::instance()->REQ->get($cntry_input) : '')), array('input_name' => $cntry_input, 'input_id' => $cntry_id, 'input_class' => $class, 'input_prefix' => '', 'append_qstn_id' => FALSE));
         $output .= EEH_Form_Fields::generate_form_input($country);
         // NEW STATE NAME
         $state_id = str_replace('state', 'new_state_name', $id);
         $state_name = str_replace('state', 'new_state_name', $name);
         $new_state_name = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => __('New State/Province Name', 'event_espresso'), 'QST_system' => '', 'QST_type' => EEM_Question::QST_type_text, 'QST_required' => FALSE)), EE_Answer::new_instance(array('ANS_value' => EE_Registry::instance()->REQ->is_set($state_name) ? EE_Registry::instance()->REQ->get($state_name) : '')), array('input_name' => $state_name, 'input_id' => $state_id, 'input_class' => $class, 'input_prefix' => '', 'append_qstn_id' => FALSE));
         $output .= EEH_Form_Fields::generate_form_input($new_state_name);
         // NEW STATE ABBREVIATION
         $abbrv_id = str_replace('state', 'new_state_abbrv', $id);
         $abbrv_name = str_replace('state', 'new_state_abbrv', $name);
         $new_state_abbrv = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => __('New State/Province Abbreviation', 'event_espresso'), 'QST_system' => '', 'QST_type' => EEM_Question::QST_type_text, 'QST_required' => FALSE)), EE_Answer::new_instance(array('ANS_value' => EE_Registry::instance()->REQ->is_set($abbrv_name) ? EE_Registry::instance()->REQ->get($abbrv_name) : '')), array('input_name' => $abbrv_name, 'input_id' => $abbrv_id, 'input_class' => $class, 'input_prefix' => '', 'append_qstn_id' => FALSE));
         // add filters for reducing size of State Abbrv text input, and adding an "ADD" button, as well as a "cancel" button
         add_filter('FHEE__EEH_Form_Fields__additional_form_field_attributes', array('EED_Add_New_State', 'set_new_state_input_size'));
         add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Add_New_State', 'add_new_state_submit_button'), 1, 3);
         add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Add_New_State', 'cancel_new_state'), 2, 3);
         $output .= EEH_Form_Fields::generate_form_input($new_state_abbrv);
         // remove the filters from above so that they don't affect any other inputs
         remove_filter('FHEE__EEH_Form_Fields__additional_form_field_attributes', array('EED_Add_New_State', 'set_new_state_input_size'));
         remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Add_New_State', 'add_new_state_submit_button'), 1, 3);
         remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Add_New_State', 'cancel_new_state'), 2, 3);
         $output .= '</div>';
     }
     return $input_html . $output;
 }
 /**
  *        generate_question_form_inputs_for_object
  *
  * @access    protected
  * @param bool|object $object $object
  * @param    array    $input_types
  * @return        array
  */
 static function generate_question_form_inputs_for_object($object = FALSE, $input_types = array())
 {
     if (!is_object($object)) {
         return FALSE;
     }
     $inputs = array();
     $fields = $object->get_model()->field_settings(FALSE);
     //		$pk = $object->ID(); <<< NO!
     //		printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     //		printr( $fields, '$fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     //		printr( $input_types, '$input_types  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     foreach ($fields as $field_ID => $field) {
         if ($field instanceof EE_Model_Field_Base) {
             //			echo '<h4>$field_ID : ' . $field_ID . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
             //			printr( $field, '$field  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
             if (isset($input_types[$field_ID])) {
                 // get saved value for field
                 $value = $object->get($field_ID);
                 //				echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                 // if no saved value, then use default
                 $value = $value !== NULL ? $value : $field->get_default_value();
                 //			if ( $field_ID == 'CNT_active' )
                 //				echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                 // determine question type
                 $type = isset($input_types[$field_ID]) ? $input_types[$field_ID]['type'] : 'TEXT';
                 // input name
                 $input_name = isset($input_types[$field_ID]) && isset($input_types[$field_ID]['input_name']) ? $input_types[$field_ID]['input_name'] . '[' . $field_ID . ']' : $field_ID;
                 // css class for input
                 $class = isset($input_types[$field_ID]['class']) && !empty($input_types[$field_ID]['class']) ? ' ' . $input_types[$field_ID]['class'] : '';
                 // whether to apply htmlentities to answer
                 $htmlentities = isset($input_types[$field_ID]['htmlentities']) ? $input_types[$field_ID]['htmlentities'] : TRUE;
                 // whether to apply htmlentities to answer
                 $label_b4 = isset($input_types[$field_ID]['label_b4']) ? $input_types[$field_ID]['label_b4'] : FALSE;
                 // whether to apply htmlentities to answer
                 $use_desc_4_label = isset($input_types[$field_ID]['use_desc_4_label']) ? $input_types[$field_ID]['use_desc_4_label'] : FALSE;
                 // create EE_Question_Form_Input object
                 $QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_ID' => 0, 'QST_display_text' => $field->get_nicename(), 'QST_type' => $type)), EE_Answer::new_instance(array('ANS_ID' => 0, 'QST_ID' => 0, 'REG_ID' => 0, 'ANS_value' => $value)), array('input_id' => $field_ID . '-' . $object->ID(), 'input_name' => $input_name, 'input_class' => $field_ID . $class, 'input_prefix' => '', 'append_qstn_id' => FALSE, 'htmlentities' => $htmlentities, 'label_b4' => $label_b4, 'use_desc_4_label' => $use_desc_4_label));
                 // does question type have options ?
                 if (in_array($type, array('DROPDOWN', 'SINGLE', 'MULTIPLE')) && isset($input_types[$field_ID]) && isset($input_types[$field_ID]['options'])) {
                     foreach ($input_types[$field_ID]['options'] as $option) {
                         $option = stripslashes_deep($option);
                         $option_id = !empty($option['id']) ? $option['id'] : 0;
                         $QSO = EE_Question_Option::new_instance(array('QSO_value' => (string) $option_id, 'QSO_desc' => $option['text'], 'QSO_deleted' => FALSE));
                         // all QST (and ANS) properties can be accessed indirectly thru QFI
                         $QFI->add_temp_option($QSO);
                     }
                 }
                 // we don't want ppl manually changing primary keys cuz that would just lead to total craziness man
                 if ($field_ID == $object->get_model()->primary_key_name()) {
                     $QFI->set('QST_disabled', TRUE);
                 }
                 //printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                 $inputs[$field_ID] = $QFI;
                 //			if ( $field_ID == 'CNT_active' ) {
                 //				printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                 //			}
             }
         }
     }
     return $inputs;
 }
 /**
  * 		generate s HTML for the billing info form during registration
  * 		@access 		protected
  * 		@param		array	$billing_inputs - array of input field details
  * 		@param		array	$section - what part of the billing info form, "address", "credit_card", or "other"
  * 		@return 		string
  */
 protected function _generate_billing_info_form_fields($billing_inputs = array(), $section = FALSE)
 {
     do_action('AHEE_log', __FILE__, __FUNCTION__, '');
     if (empty($billing_inputs) || !$section) {
         return;
     }
     global $wp_filter, $css_class;
     // fill out section name
     $section = '_billing_info_' . $section . '_fields';
     // if you don't behave - this is what you're gonna get !!!
     $output = '';
     // cycle thru billing inputs
     foreach ($billing_inputs as $input_key => $billing_input) {
         // is the billing input in the requested section	?
         if (in_array($input_key, $this->{$section})) {
             // required fields get a *
             $required = $billing_input['required'] ? EEH_Form_Fields::prep_required(array('class' => 'required', 'label' => '<em>*</em>')) : '';
             // answer
             $answer = EE_Registry::instance()->REQ->is_set($input_key) ? EE_Registry::instance()->REQ->get($input_key) : $billing_input['value'];
             if ($input_key == '_reg-page-billing-card-exp-date-mnth-' . $this->_gateway_name) {
                 // Credit Card MONTH
                 add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_month_input_wrap'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2);
                 $output .= EEH_Form_Fields::select(__('Expiry Date', 'event_espresso'), $answer, EEH_Form_Fields::two_digit_months_dropdown_options(), $input_key, $input_key, $css_class . ' ee-credit-card-month display-inline small-txt', $required, '', '', '', FALSE, TRUE, FALSE);
                 remove_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_month_input_wrap'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2);
                 $output .= "\n\t\t\t" . '&nbsp;/&nbsp;';
             } elseif ($input_key == '_reg-page-billing-card-exp-date-year-' . $this->_gateway_name) {
                 // Credit Card YEAR
                 // remove label
                 add_filter('FHEE__EEH_Form_Fields__label_html', array('EEH_Form_Fields', 'remove_label_keep_required_msg'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_year_input_wrap'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2);
                 $output .= EEH_Form_Fields::select(__('Year', 'event_espresso'), $answer, EEH_Form_Fields::next_decade_two_digit_year_dropdown_options(), $input_key, $input_key, $css_class . ' ee-credit-card-year display-inline small-txt', $required, '', '', '', FALSE, TRUE, FALSE);
                 // remove filter that removes label, or else no other inputs will have labels
                 remove_filter('FHEE__EEH_Form_Fields__label_html', array('EEH_Form_Fields', 'remove_label_keep_required_msg'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_year_input_wrap'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2);
                 $output .= "\n\t\t\t" . '<span class="small-text lt-grey-text">' . __('(mm/yy)', 'event_espresso') . '</span>';
             } else {
                 // create question form input
                 $QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => $billing_input['label'], 'QST_system' => $billing_input['db-col'], 'QST_type' => $billing_input['input'], 'QST_required' => $billing_input['required'])), EE_Answer::new_instance(array('ANS_value' => $answer)), array('input_name' => $input_key, 'input_id' => $input_key, 'input_class' => $css_class, 'input_prefix' => '', 'append_qstn_id' => FALSE));
                 // add options
                 if (isset($billing_input['options'])) {
                     $options = is_array($billing_input['options']) ? $billing_input['options'] : explode(',', $billing_input['options']);
                     foreach ($options as $option) {
                         $QSO = EE_Question_Option::new_instance(array('QSO_value' => $option, 'QSO_desc' => $option));
                         $QFI->add_temp_option($QSO);
                     }
                 }
                 $output .= EEH_Form_Fields::generate_form_input($QFI);
             }
         }
         // end if ( in_array( $input_key, $this->$section ))
     }
     // end foreach( $billing_inputs as $input_key => $billing_input )
     return $output;
 }
 /**
  *        load and display the Registration Single Page Checkout
  *
  * @access 	public
  * @param 	bool $from_admin
  * @return 	string
  */
 public function registration_checkout($from_admin = FALSE)
 {
     do_action('AHEE_log', __FILE__, __FUNCTION__, '');
     //d($this->_cart);
     EE_Registry::instance()->load_helper('Form_Fields');
     EE_Registry::instance()->load_helper('Template');
     EE_Registry::instance()->load_class('Question_Form_Input', array(), FALSE, FALSE, TRUE);
     $event_queue = array();
     $total_items = 0;
     $ticket_count = array();
     $payment_required = FALSE;
     $sold_out_events = array();
     $events_requiring_pre_approval = array();
     $additional_event_attendees = array();
     //		$events_that_use_coupon_codes = array();
     //		$events_that_use_groupon_codes = array();
     $template_args = array('css_class' => '', 'confirmation_data' => '', 'reg_page_discounts_dv_class' => 'hidden', 'additional_attendee_reg_info' => NULL, 'whats_in_the_cart' => '', 'prmy_att_input_name' => NULL);
     $event_queue['title'] = __('Registrations', 'event_espresso');
     $additional_attendee_forms = FALSE;
     $registrations = $this->_transaction->registrations(array(), TRUE);
     // grab the saved registrations from the transaction
     if ($this->_transaction instanceof EE_Transaction && $registrations !== NULL) {
         //d( $this->_transaction );
         $event_queue['has_items'] = TRUE;
         $prev_event = NULL;
         foreach ($registrations as $registration) {
             if (($registration->event()->is_sold_out() || $registration->event()->is_sold_out(TRUE)) && !$this->_reg_url_link == $registration->reg_url_link()) {
                 // add event to list of events that are sold out
                 $sold_out_events[$registration->event()->ID()] = '<li><span class="dashicons dashicons-marker ee-icon-size-16 pink-text"></span>' . $registration->event()->name() . '</li>';
             }
             $payment_required = $registration->status_ID() == EEM_Registration::status_id_pending_payment || $registration->status_ID() == EEM_Registration::status_id_approved ? TRUE : $payment_required;
             if (!$payment_required && !$this->_reg_url_link == $registration->reg_url_link()) {
                 // add event to list of events with pre-approval reg status
                 $events_requiring_pre_approval[$registration->event()->ID()] = '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>' . $registration->event()->name() . '</li>';
             }
             $total_items++;
             $ticket_count[$registration->ticket()->ID()] = isset($ticket_count[$registration->ticket()->ID()]) ? $ticket_count[$registration->ticket()->ID()] + 1 : 1;
             $line_item_ID = $registration->reg_url_link();
             $event_queue['items'][$line_item_ID]['ticket'] = $registration->ticket();
             $event_queue['items'][$line_item_ID]['event'] = $registration->event();
             $event_queue['items'][$line_item_ID]['reg_count'] = $registration->count();
             // do we need to generate data regarding attendees and reg form questions?
             if (strpos($this->_current_step, 'attendee_information') !== FALSE) {
                 $question_meta = array('EVT_ID' => $registration->event()->ID(), 'att_nmbr' => $registration->count(), 'ticket_id' => $registration->ticket()->ID(), 'input_name' => '[' . $line_item_ID . ']', 'input_id' => $line_item_ID, 'input_class' => 'ee-reg-page-questions' . $template_args['css_class']);
                 $Question_Groups = EE_Registry::instance()->load_model('Question_Group')->get_all(array(array('Event.EVT_ID' => $registration->event()->ID(), 'Event_Question_Group.EQG_primary' => $registration->count() == 1 ? TRUE : FALSE), 'order_by' => array('QSG_order' => 'ASC')));
                 foreach ($Question_Groups as $QSG_ID => $Question_Group) {
                     $where = array('QST_deleted' => 0);
                     if (!$from_admin) {
                         $where['QST_admin_only'] = 0;
                     }
                     $Questions = $Question_Group->get_many_related('Question', array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC')));
                     foreach ($Questions as $Question) {
                         if ($Question instanceof EE_Question) {
                             // if this question was for an attendee detail, then check for that answer
                             $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value($registration, $Question->ID());
                             $answer = $this->_reg_url_link || !$answer_value ? EEM_Answer::instance()->get_one(array(array('QST_ID' => $Question->ID(), 'REG_ID' => $registration->ID()))) : NULL;
                             // if NOT returning to edit an existing registration OR if this question is for an attendee property OR we still don't have an EE_Answer object
                             if (!$this->_reg_url_link || $answer_value || !$answer instanceof EE_Answer) {
                                 // create an EE_Answer object for storing everything in
                                 $answer = EE_Answer::new_instance(array('QST_ID' => $Question->ID(), 'REG_ID' => $registration->ID()));
                             }
                             if ($answer instanceof EE_Answer) {
                                 if (!empty($answer_value)) {
                                     $answer->set('ANS_value', $answer_value);
                                 }
                                 $question_meta['attendee'][$Question->is_system_question() ? $Question->system_ID() : $Question->ID()] = $answer->value();
                                 $answer->cache('Question', $Question);
                                 $answer_cache_id = $Question->system_ID() != NULL ? $Question->system_ID() . '-' . $line_item_ID : $Question->ID() . '-' . $line_item_ID;
                                 //								echo '<h4>$answer_cache_id : ' . $answer_cache_id . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                                 $registration->cache('Answer', $answer, $answer_cache_id);
                             }
                             $Question_Groups[$QSG_ID]->cache('Question', $Question);
                         }
                     }
                 }
                 //					printr( $registration, '$registration  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                 add_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2);
                 $attendee_questions = EEH_Form_Fields::generate_question_groups_html2($Question_Groups, $question_meta, $from_admin, 'div');
                 // show this attendee form?
                 if (empty($attendee_questions)) {
                     $event_queue['items'][$line_item_ID]['additional_attendee_reg_info'] = "\n" . '<input type="hidden" id="' . $line_item_ID . '-additional_attendee_reg_info" name="qstn[' . $line_item_ID . '][additional_attendee_reg_info]" value="0" />' . "\n";
                 } else {
                     $additional_attendee_forms = $registration->count() == 1 ? FALSE : TRUE;
                     $event_queue['items'][$line_item_ID]['additional_attendee_reg_info'] = '';
                 }
                 $event_queue['items'][$line_item_ID]['attendee_questions'] = $attendee_questions;
                 // is this the primary registrant ?
                 if ($registration->count() == 1) {
                     // grab line item from primary attendee
                     $template_args['prmy_att_input_name'] = $line_item_ID;
                 } else {
                     // for all  attendees other than the primary attendee
                     $additional_event_attendees[$registration->ticket()->ID()][$line_item_ID] = array('ticket' => $registration->ticket()->name(), 'att_nmbr' => $registration->count(), 'input_id' => $line_item_ID, 'input_name' => '[' . $line_item_ID . ']');
                     $item_name = $registration->ticket()->name();
                     $item_name .= $registration->ticket()->description() != '' ? ' - ' . $registration->ticket()->description() : '';
                     // if this is a new ticket OR if this is the very first additional attendee after the primary attendee
                     if ($registration->ticket()->ID() != $prev_event || $registration->count() == 2) {
                         $additional_event_attendees[$registration->ticket()->ID()][$line_item_ID]['event_hdr'] = $item_name;
                         $prev_event = $registration->ticket()->ID();
                     } else {
                         // no heading
                         $additional_event_attendees[$registration->ticket()->ID()][$line_item_ID]['event_hdr'] = FALSE;
                     }
                 }
             }
         }
         if (!$this->_reg_url_link) {
             EE_Registry::instance()->SSN->set_session_data(array('transaction' => $this->_transaction));
         }
         //				echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
         //				EE_Registry::instance()->SSN->update();
         //				d( $this->_transaction );
         //				d( $this->_cart );
     } else {
         // empty
         $event_queue['has_items'] = FALSE;
     }
     // sold_out_events
     $template_args['sold_out_events'] = implode($sold_out_events);
     $template_args['sold_out_events_msg'] = apply_filters('FHEE__Single_Page_Checkout__registration_checkout__sold_out_events_msg', __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'));
     // events_requiring_pre_approval
     $template_args['events_requiring_pre_approval'] = implode($events_requiring_pre_approval);
     $template_args['events_requiring_pre_approval_msg'] = apply_filters('FHEE__Single_Page_Checkout__registration_checkout__sold_out_events_msg', __('The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso'));
     //  GOT COUPONS ?
     $template_args['events_that_use_coupon_codes'] = '';
     $template_args['use_coupon_codes'] = FALSE;
     // Groupons ?
     $template_args['events_that_use_groupon_codes'] = '';
     $template_args['use_groupon_codes'] = FALSE;
     $template_args['spco_reg_page_ajax_coupons_url'] = add_query_arg(array('ee' => 'apply_coupon'), $this->_reg_page_base_url);
     //		$template_args['print_copy_info'] = $additional_attendee_forms || $total_items > 2 ? TRUE : FALSE;
     $template_args['total_items'] = $total_items;
     $template_args['ticket_count'] = $ticket_count;
     $template_args['print_copy_info'] = $additional_attendee_forms;
     //		d($additional_event_attendees);
     $template_args['additional_event_attendees'] = $additional_event_attendees;
     // total monies paid to date
     $total_payments = 0;
     // the original total
     $cart_total_before_tax = $this->_cart->get_cart_total_before_tax();
     // get cart total
     $grand_total = $this->_cart->get_cart_grand_total();
     $template_args['grand_total'] = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__grand_total', $grand_total);
     // check if monies are potentially owing
     $template_args['payment_required'] = $cart_total_before_tax > 0 ? $payment_required : FALSE;
     // not a free event?
     if ($template_args['payment_required']) {
         //check for any previous payments
         if ($template_args['payments'] = $this->_transaction->approved_payments()) {
             foreach ($template_args['payments'] as $payment) {
                 if ($payment instanceof EE_Payment) {
                     // increment total payments
                     $total_payments += $payment->amount();
                 }
             }
             $template_args['pay_date_frmt'] = get_option('date_format') . ' ' . get_option('time_format');
         }
     } else {
         //unset( self::$_reg_steps['payment_options'] );
         EE_Registry::instance()->SSN->set_session_data(array('billing_info' => 'no payment required'));
         $template_args['payments'] = array();
     }
     $template_args['sub_total'] = $cart_total_before_tax;
     $template_args['taxes'] = $this->_cart->get_taxes_line_item()->children();
     // what's left to pay?
     $amount_owing = $grand_total - $total_payments;
     $template_args['amount_owing'] = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__amount_owing', $amount_owing);
     //$template_args['grand_total'] = $template_args['amount_owing'] !== FALSE ? $amount_owing : $grand_total;
     $template_args['total_items'] = $event_queue['total_items'] = $total_items;
     //	d( $event_queue );
     $template_args['event_queue'] = $event_queue;
     $template_args['images_dir_url'] = EE_GLOBAL_ASSETS_URL . 'images/';
     $template_args['reg_url_link'] = $this->_reg_url_link;
     $template_args['return_url'] = add_query_arg(array('ee' => 'event_queue'), $this->_reg_page_base_url);
     $template_args['update_url'] = add_query_arg(array('ee' => 'update_event_queue'), $this->_reg_page_base_url);
     $template_args['register_url'] = add_query_arg(array('ee' => '_register'), $this->_reg_page_base_url);
     $template_args['event_queue_url'] = add_query_arg(array('ee' => 'event_queue'), $this->_reg_page_base_url);
     $template_args['confirmation_data'] = $this->_current_step == 'registration_confirmation' ? $this->_registration_confirmation() : '';
     $step_or_revisit = __('Step ', 'event_espresso');
     if ($this->_revisit && $this->_current_step == 'attendee_information') {
         // Update Registration Details
         $confirmation_btn_text = sprintf(__('Update%1$sRegistration%1$sDetails', 'event_espresso'), '&nbsp;');
         $confirmation_btn_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $confirmation_btn_text);
         $step_or_revisit = __('Edit', 'event_espresso');
     } else {
         if ($this->_revisit && $this->_current_step == 'payment_options') {
             // Process Payment
             $confirmation_btn_text = sprintf(__('Process%1$sPayment', 'event_espresso'), '&nbsp;');
             $confirmation_btn_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $confirmation_btn_text);
             $step_or_revisit = '';
         } else {
             // Finalize Registration
             $confirmation_btn_text = sprintf(__('Finalize%1$sRegistration', 'event_espresso'), '&nbsp;');
             $confirmation_btn_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $confirmation_btn_text);
         }
     }
     // grand total less than paid but greater than zero ?
     if ($grand_total < $this->_transaction->paid() && $grand_total > 0 && $this->_next_step == 'payment_options') {
         // owing money
         $proceed_to_payment_btn_text = sprintf(__('%1$s%2$s%1$sProceed%1$sto%1$sPayment', 'event_espresso'), '&nbsp;', '&amp;');
         $confirmation_btn_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $proceed_to_payment_btn_text);
     }
     add_action('AHEE__SPCO_after_reg_step_form', array($this, 'add_extra_finalize_registration_inputs'), 10, 2);
     $template_args['from_admin'] = $from_admin;
     //if in admin we exit at this point and display the questions template
     if ($from_admin) {
         //some custom template args
         $template_args['step_dv_class'] = '';
         $template_args['revisit'] = $this->_revisit;
         return EEH_Template::display_template($this->_templates['registration_page_attendee_information'], $template_args, TRUE);
     }
     $proceed_to_btn_text = sprintf(__('Proceed%1$sto%1$s', 'event_espresso'), '&nbsp;');
     $proceed_to_btn_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $proceed_to_btn_text);
     $registration_steps = '';
     $step_nmbr = 1;
     // set pointer to first step
     reset(self::$_reg_steps);
     // loop through steps
     while ($reg_step_details = current(self::$_reg_steps)) {
         $reg_step = key(self::$_reg_steps);
         //			echo '<br/><h4>$reg_step : ' . $reg_step . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
         //			echo '<h4>$this->_current_step : ' . $this->_current_step . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
         $edit_lnk_class = $this->_current_step == $reg_step ? ' hidden' : '';
         $edit_lnk_url = add_query_arg(array('ee' => '_register', 'step' => $reg_step_details['display_func']), $this->_reg_page_base_url);
         $step_dv_class = $this->_current_step == $reg_step ? '' : ' hidden';
         $reg_step_form_url = add_query_arg(array('ee' => '_register', 'step' => $reg_step_details['process_func']), $this->_reg_page_base_url);
         $next = $this->_get_next_reg_step();
         //d( $next );
         $next_step = $next ? $next['display_func'] : 'finalize_registration';
         $next_step_text = $next ? $proceed_to_btn_text . $next['name'] : $confirmation_btn_text;
         $step_args = array_merge($template_args, array('step' => $reg_step, 'step_nmbr' => $this->_revisit !== FALSE ? $step_or_revisit : $step_or_revisit . $step_nmbr . ' - ', 'edit_lnk_class' => $edit_lnk_class, 'edit_lnk_url' => $edit_lnk_url, 'step_dv_class' => $step_dv_class, 'reg_step_form_url' => $reg_step_form_url, 'reg_step_ajax_action' => $reg_step_details['process_func'], 'next_step' => $next_step, 'next_step_text' => $next_step_text, 'revisit' => $this->_revisit));
         if ($reg_step == 'payment_options') {
             EE_Registry::instance()->load_model('Gateways');
             // has gateway been set by no-js user?
             if (EE_Registry::instance()->REQ->is_set('payment')) {
                 if ($payment = sanitize_text_field(EE_Registry::instance()->REQ->get('payment'))) {
                     //						d( $payment );
                     if (EE_Registry::instance()->LIB->EEM_Gateways->selected_gateway() != $payment) {
                         EE_Registry::instance()->LIB->EEM_Gateways->set_selected_gateway($payment);
                     } else {
                         EE_Registry::instance()->LIB->EEM_Gateways->unset_selected_gateway($payment);
                     }
                 }
             }
             $step_args['selected_gateway'] = EE_Registry::instance()->LIB->EEM_Gateways->selected_gateway();
         } else {
             $step_args['selected_gateway'] = '';
         }
         //			printr( $step_args, '$step_args  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
         //			d( $step_args );
         $registration_steps .= EEH_Template::locate_template($this->_templates[$reg_step_details['template']], $step_args, TRUE, TRUE);
         // pass step info to js
         EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step_details['display_func'];
         next(self::$_reg_steps);
         $step_nmbr++;
     }
     EE_Registry::$i18n_js_strings['reg_steps'][] = 'finalize_registration';
     $wrapper_args = array('step' => $this->_current_step, 'empty_cart' => $total_items < 1 ? TRUE : FALSE, 'reg_steps' => self::$_reg_steps, 'registration_steps' => $registration_steps, 'revisit' => $this->_revisit, 'empty_msg' => apply_filters('FHEE__Single_Page_Checkout__registration_checkout__empty_msg', __('You need to select at least one event before you can proceed with the registration process.', 'event_espresso')));
     //		d( $wrapper_args );
     EE_Registry::instance()->REQ->add_output(EEH_Template::locate_template($this->_templates['registration_page_wrapper'], $wrapper_args, TRUE, TRUE));
 }
 /**
  * decaf venue metabox
  * @return string form for Event Venue
  */
 public function venue_metabox()
 {
     //first let's see if we have a venue already
     $event_id = $this->_cpt_model_obj->ID();
     $venue = !empty($event_id) ? $this->_cpt_model_obj->venues() : NULL;
     $venue = empty($venue) ? EE_Registry::instance()->load_model('Venue')->create_default_object() : array_shift($venue);
     $template_args['_venue'] = $venue;
     $template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input($QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => 'State', 'QST_system' => 'state')), EE_Answer::new_instance(array('ANS_value' => $venue->state_ID())), array('input_name' => 'state', 'input_id' => 'phys-state', 'input_class' => '', 'input_prefix' => '', 'append_qstn_id' => FALSE)));
     $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input($QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => 'Country', 'QST_system' => 'country')), EE_Answer::new_instance(array('ANS_value' => $venue->country_ID())), array('input_name' => 'countries', 'input_id' => 'phys-country', 'input_class' => '', 'input_prefix' => '', 'append_qstn_id' => FALSE)));
     $template_path = EVENTS_TEMPLATE_PATH . 'event_venues_metabox_content.template.php';
     EEH_Template::display_template($template_path, $template_args);
 }
 /**
  * Gets the list of states for the form input
  *
  * @param array|null $states_list
  * @param EE_Question $question
  * @param EE_Registration $registration
  * @return array 2d keys are state IDs, values are their names
  */
 public function use_cached_states_for_form_input($states_list, $question, $registration, $answer)
 {
     $state_options = array('' => array('' => ''));
     $states = $this->checkout->action == 'process_reg_step' ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_active_states();
     if (!empty($states)) {
         foreach ($states as $state) {
             if ($state instanceof EE_State) {
                 $state_options[$state->country()->name()][$state->ID()] = $state->name();
             }
         }
     }
     if ($question instanceof EE_Question && $registration instanceof EE_Registration) {
         $answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())));
     } else {
         $answer = EE_Answer::new_instance();
     }
     $state_options = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', $state_options, $this, $registration, $question, $answer);
     return $state_options;
 }