/**
  * filter_checkout_request_params
  *
  * recursively drills down through request params to remove any that were added by this module
  *
  * @access public
  * @param array $request_params
  * @return array
  */
 public static function filter_checkout_request_params($request_params)
 {
     foreach ($request_params as $form_section) {
         if (is_array($form_section)) {
             EED_Add_New_State::unset_new_state_request_params($form_section);
             EED_Add_New_State::filter_checkout_request_params($form_section);
         }
     }
     return $request_params;
 }
 /**
  * 	set_new_state_input_width
  *
  * 	@access 	public
  * 	@return 		mixed 	string | int
  */
 public static function add_new_state()
 {
     $REQ = EE_Registry::instance()->load_core('Request_Handler');
     if ($REQ->is_set('add_new_state') && $REQ->get('add_new_state') == 1) {
         EE_Registry::instance()->load_model('State');
         // grab country ISO code, new state name, and new state abbreviation
         $state_country = $REQ->is_set('new_state_country') ? sanitize_text_field($REQ->get('new_state_country')) : FALSE;
         $state_name = $REQ->is_set('new_state_name') ? sanitize_text_field($REQ->get('new_state_name')) : FALSE;
         $state_abbr = $REQ->is_set('new_state_abbrv') ? sanitize_text_field($REQ->get('new_state_abbrv')) : FALSE;
         //echo '<h4>$state_country : ' . $state_country . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
         //echo '<h4>$state_name : ' . $state_name . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
         //echo '<h4>$state_abbr : ' . $state_abbr . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
         if ($state_country && $state_name && $state_abbr) {
             $new_state = EED_Add_New_State::save_new_state_to_db(array('CNT_ISO' => strtoupper($state_country), 'STA_abbrev' => strtoupper($state_abbr), 'STA_name' => ucwords($state_name), 'STA_active' => FALSE));
             if ($new_state instanceof EE_State) {
                 // clean house
                 EE_Registry::instance()->REQ->un_set('add_new_state');
                 EE_Registry::instance()->REQ->un_set('new_state_country');
                 EE_Registry::instance()->REQ->un_set('new_state_name');
                 EE_Registry::instance()->REQ->un_set('new_state_abbrv');
                 if (EE_Registry::instance()->REQ->ajax) {
                     echo json_encode(array('success' => TRUE, 'id' => $new_state->ID(), 'name' => $new_state->name(), 'abbrev' => $new_state->abbrev(), 'country_iso' => $new_state->country_iso(), 'country_name' => $new_state->country()->name()));
                     exit;
                 } else {
                     return $new_state->ID();
                 }
             }
         } else {
             $error = __('A new State/Province could not be added because invalid or missing data was received.', 'event_espresso');
             if (EE_Registry::instance()->REQ->ajax) {
                 echo json_encode(array('error' => $error));
                 exit;
             } else {
                 EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
             }
         }
     }
 }
 /**
  * 	country_options
  *
  * @access        public
  * @param EE_Country[]  $country_options
  * @return        boolean
  */
 public static function country_options($country_options = array())
 {
     $new_states = EED_Add_New_State::_get_new_states();
     foreach ($new_states as $new_state) {
         if ($new_state instanceof EE_State && $new_state->country() instanceof EE_Country) {
             $country_options[$new_state->country()->ID()] = $new_state->country()->name();
         }
     }
     return $country_options;
 }