}
/* ---- Delete field ---- */
if ($field_id != '' && $field_action == 'delete' && isset($_REQUEST['_wpnonce'])) {
    if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'custom_advance_search_fields_' . $field_id)) {
        return;
    }
    echo geodir_custom_advance_search_field_delete($field_id);
}
/* ---- Save field  ---- */
if ($field_id != '' && $field_action == 'submit' && isset($_REQUEST['_wpnonce'])) {
    if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'custom_advance_search_fields_' . $field_id)) {
        return;
    }
    foreach ($_REQUEST as $pkey => $pval) {
        if (is_array($_REQUEST[$pkey])) {
            $tags = 'skip_field';
        } else {
            $tags = '';
        }
        if ($tags != 'skip_field') {
            $_REQUEST[$pkey] = strip_tags($_REQUEST[$pkey], $tags);
        }
    }
    $return = geodir_custom_advance_search_field_save($_REQUEST);
    if (is_int($return)) {
        $lastid = $return;
        geodir_custom_advance_search_field_adminhtml($field_type, $lastid, 'submit');
    } else {
        echo $return;
    }
}
function geodir_advace_search_selected_fields()
{
    global $wpdb;
    $listing_type = $_REQUEST['listing_type'] != '' ? $_REQUEST['listing_type'] : 'gd_place';
    ?>
	<input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php 
    echo $_REQUEST['subtab'];
    ?>
" />
	<ul class="advance"><?php 
    $fields = $wpdb->get_results($wpdb->prepare("select * from  " . GEODIR_ADVANCE_SEARCH_TABLE . " where post_type = %s order by sort_order asc", array($listing_type)));
    if (!empty($fields)) {
        foreach ($fields as $field) {
            //$result_str = $field->id;
            $result_str = $field;
            $field_type = $field->field_site_type;
            $field_ins_upd = 'display';
            $default = false;
            geodir_custom_advance_search_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
        }
    }
    ?>
		
		</ul>
	<?php 
}