/** * display_country_states * * @access public * @param string $CNT_ISO * @return string */ public function display_country_states($CNT_ISO = '') { $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; if (!$CNT_ISO) { return ''; } // for ajax remove_all_filters('FHEE__EEH_Form_Fields__label_html'); remove_all_filters('FHEE__EEH_Form_Fields__input_html'); add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); // echo '<h4>$CNT_ISO : ' . $CNT_ISO . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; // global $wpdb; // echo '<h4>' . $wpdb->last_query . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; // EEH_Debug_Tools::printr( $states, '$states <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); if ($states) { foreach ($states as $STA_ID => $state) { if ($state instanceof EE_State) { //STA_abbrev STA_name STA_active $state_input_types = array('STA_abbrev' => array('type' => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'mid-text'), 'STA_name' => array('type' => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'regular-text'), 'STA_active' => array('type' => 'RADIO_BTN', 'input_name' => 'states[' . $STA_ID . ']', 'options' => $this->_yes_no_values, 'use_desc_4_label' => true)); $this->_template_args['states'][$STA_ID]['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($state, $state_input_types); $query_args = array('action' => 'delete_state', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'STA_abbrev' => $state->abbrev()); $this->_template_args['states'][$STA_ID]['delete_state_url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, GEN_SET_ADMIN_URL); } } } else { $this->_template_args['states'] = FALSE; } // EEH_Debug_Tools::printr( $this->_template_args['states'], 'states <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'add_new_state'), GEN_SET_ADMIN_URL); $state_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', $this->_template_args, TRUE); if (defined('DOING_AJAX')) { $notices = EE_Error::get_notices(FALSE, FALSE, FALSE); echo json_encode(array('return_data' => $state_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors'])); die; } else { return $state_details_settings; } }