function geodir_show_filters_fields($post_type)
{
    global $wpdb;
    $post_types = geodir_get_posttypes();
    $post_type = $post_type && in_array($post_type, $post_types) ? $post_type : $post_types[0];
    $geodir_list_date_type = 'yy-mm-dd';
    $datepicker_formate = $wpdb->get_var("SELECT `extra_fields`  FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE `post_type` = '" . $post_type . "' AND data_type ='DATE'");
    $datepicker_formate_arr = unserialize($datepicker_formate);
    if ($datepicker_formate_arr['date_format']) {
        $geodir_list_date_type = $datepicker_formate_arr['date_format'];
    }
    $geodir_search_field_selected = false;
    $geodir_search_field_selected_str = '';
    $geodir_search_field_begin = '';
    $geodir_search_field_end = '';
    $geodir_search_custom_value_str = '';
    ?>
		<script language="javascript">
            jQuery(function($) {
                var gd_datepicker_loaded = $('body').hasClass('gd-multi-datepicker') ? true : false;

				var gdcnt = 0;
				$('.geodir-listing-search #event_start').each(function(){
					gdcnt++;
					$(this).attr('id', 'event_start'+gdcnt);
					$(this).addClass('gd-datepicker-event-start');
				});
				
				var gdcnt = 0;
				$('.geodir-listing-search #event_end').each(function(){
					gdcnt++;
					$(this).attr('id', 'event_end'+gdcnt);
					$(this).addClass('gd-datepicker-event-end');
				});
				
				if(!gd_datepicker_loaded){
					$('body').addClass('gd-multi-datepicker');
					
					$('.gd-datepicker-event-start').each(function(){
						var $this = this;
						$($this).datepicker({
							dateFormat:'<?php 
    echo $geodir_list_date_type;
    ?>
',changeMonth: true, changeYear: true,
							onClose: function( selectedDate ) {
								$($this).closest('div').find('.gd-datepicker-event-end').datepicker( "option", "minDate", selectedDate );
							}
						});
					});
					
					$('.gd-datepicker-event-end').each(function(){
						$(this).datepicker({changeMonth: true, changeYear: true,dateFormat:'<?php 
    echo $geodir_list_date_type;
    ?>
'});
					});
				}
            });
        </script>
		<?php 
    $taxonomies = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_ADVANCE_SEARCH_TABLE . " WHERE post_type = %s  ORDER BY sort_order", array($post_type)));
    ob_start();
    if (!empty($taxonomies)) {
        foreach ($taxonomies as $taxonomy_obj) {
            $taxonomy_obj = stripslashes_deep($taxonomy_obj);
            // strip slashes
            if (!stristr($taxonomy_obj->site_htmlvar_name, 'tag')) {
                echo '<div class="geodir-filter-cat">';
                ?>
					<span><?php 
                if ($taxonomy_obj->front_search_title) {
                    echo $taxonomy_obj->front_search_title;
                } else {
                    echo $taxonomy_obj->field_site_name;
                }
                ?>
 </span>
					<?php 
                $geodir_search_field_begin = '';
                $geodir_search_field_end = '';
                if ($taxonomy_obj->field_input_type == 'SELECT') {
                    $geodir_search_field_begin = '<select name="s' . $taxonomy_obj->site_htmlvar_name . '[]' . '" class="cat_select"> <option value="" >' . __('Select option', GEODIRADVANCESEARCH_TEXTDOMAIN) . '</option>';
                    //$geodir_search_field_selected_str = ' selected="selected" ';
                    $geodir_search_field_end = '</select>';
                }
                ######### FETCH SEARCH OPTIONS AND DATE TIME SCRIPT #####
                switch ($taxonomy_obj->field_site_type) {
                    case 'taxonomy':
                        if ($taxonomy_obj->field_input_type == 'SELECT') {
                            $args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true);
                        } else {
                            $args = array('orderby' => 'count', 'order' => 'DESC', 'hide_empty' => true);
                        }
                        $terms = apply_filters('geodir_filter_terms', get_terms($taxonomy_obj->site_htmlvar_name, $args));
                        // let's order the child categories below the parent.
                        $terms_temp = array();
                        foreach ($terms as $term) {
                            if ($term->parent == '0') {
                                $terms_temp[] = $term;
                                foreach ($terms as $temps) {
                                    if ($temps->parent != '0' && $temps->parent == $term->term_id) {
                                        $temps->name = '- ' . $temps->name;
                                        $terms_temp[] = $temps;
                                    }
                                }
                            }
                        }
                        $terms = array();
                        $terms = $terms_temp;
                        break;
                    case 'datepicker':
                        ?>
							<script type="text/javascript" language="javascript">
                            
                             jQuery(document).ready(function(){
                                
                                jQuery( "#s<?php 
                        echo $taxonomy_obj->site_htmlvar_name;
                        ?>
" ).datepicker({changeMonth: true,	changeYear: true,dateFormat:'<?php 
                        echo $geodir_list_date_type;
                        ?>
'});
                                
                                jQuery( "#smin<?php 
                        echo $taxonomy_obj->site_htmlvar_name;
                        ?>
" ).datepicker({changeMonth: true,	changeYear: true,dateFormat:'<?php 
                        echo $geodir_list_date_type;
                        ?>
',onClose: function( selectedDate ) {
								jQuery( "#smax<?php 
                        echo $taxonomy_obj->site_htmlvar_name;
                        ?>
" ).datepicker( "option", "minDate", selectedDate );
								}
							});
                                
                                jQuery( "#smax<?php 
                        echo $taxonomy_obj->site_htmlvar_name;
                        ?>
" ).datepicker({changeMonth: true,	changeYear: true,dateFormat:'<?php 
                        echo $geodir_list_date_type;
                        ?>
'});
                                
                                });
                            
                       </script>
                   		 <?php 
                        $terms = array(1);
                        break;
                    case 'time':
                        ?>
							<script type="text/javascript" language="javascript">
                       jQuery(document).ready(function(){
			
							jQuery( "#s<?php 
                        echo $taxonomy_obj->site_htmlvar_name;
                        ?>
" ).timepicker({
									showPeriod: true,
									showLeadingZero: true,
									showPeriod: true
							});
							
							jQuery( "#smin<?php 
                        echo $taxonomy_obj->site_htmlvar_name;
                        ?>
" ).timepicker({
									showPeriod: true,
									showLeadingZero: true,
									showPeriod: true,
									onClose: function( selectedTime ) {
										jQuery( "#smax<?php 
                        echo $taxonomy_obj->site_htmlvar_name;
                        ?>
").timepicker( "option", "minTime", selectedTime );
								}
									
							});
							
							jQuery( "#smax<?php 
                        echo $taxonomy_obj->site_htmlvar_name;
                        ?>
" ).timepicker({
									showPeriod: true,
									showLeadingZero: true,
									showPeriod: true
							});
						});
                   </script>
						<?php 
                        $terms = array(1);
                        break;
                    case 'select':
                    case 'radio':
                    case 'multiselect':
                        $select_fields_result = $wpdb->get_row($wpdb->prepare("SELECT option_values  FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s and htmlvar_name=%s  ORDER BY sort_order", array($post_type, $taxonomy_obj->site_htmlvar_name)));
                        if (in_array($taxonomy_obj->field_input_type, array('CHECK', 'SELECT', 'LINK'))) {
                            // optgroup
                            $terms = geodir_string_values_to_options($select_fields_result->option_values);
                        } else {
                            $terms = explode(',', $select_fields_result->option_values);
                        }
                        break;
                    default:
                        $terms = array(1);
                        break;
                }
                ######### END  #####
                if (!empty($terms)) {
                    $expandbutton = '';
                    $expand_custom_value = $taxonomy_obj->expand_custom_value;
                    $search_condition = $taxonomy_obj->search_condition;
                    $field_input_type = $taxonomy_obj->field_input_type;
                    $expand_search = 0;
                    if (!empty($taxonomy_obj->expand_search) && ($field_input_type == 'LINK' || $field_input_type == 'CHECK' || $field_input_type == 'RADIO' || $field_input_type == 'RANGE')) {
                        $expand_search = (int) $taxonomy_obj->expand_search;
                    }
                    $moreoption = '';
                    if (!empty($expand_search) && $expand_search > 0) {
                        if ($expand_custom_value) {
                            $moreoption = $expand_custom_value;
                        } else {
                            $moreoption = 5;
                        }
                    }
                    $ulid = '';
                    if ($taxonomy_obj->search_condition == "RADIO") {
                        $ulid = ' id="sdist"';
                        if ($taxonomy_obj->site_htmlvar_name == 'dist' && $taxonomy_obj->extra_fields != '') {
                            $extra_fields = unserialize($taxonomy_obj->extra_fields);
                            $sort_options = '';
                            if ($extra_fields['is_sort'] == '1') {
                                if ($extra_fields['asc'] == '1') {
                                    $name = !empty($extra_fields['asc_title']) ? $extra_fields['asc_title'] : 'Nearest';
                                    $selected = '';
                                    if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] == 'nearest') {
                                        $selected = 'selected="selected"';
                                    }
                                    $sort_options .= '<option ' . $selected . ' value="nearest">' . $name . '</option>';
                                }
                                if ($extra_fields['desc'] == '1') {
                                    $name = !empty($extra_fields['desc_title']) ? $extra_fields['desc_title'] : 'Farthest';
                                    $selected = '';
                                    if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] == 'farthest') {
                                        $selected = 'selected="selected"';
                                    }
                                    $sort_options .= '<option ' . $selected . ' value="farthest">' . $name . '</option>';
                                }
                            }
                            if ($sort_options != '') {
                                echo '<ul><select id="" class="cat_select" name="sort_by">';
                                echo '<option value="">' . __('Select Option', GEODIRADVANCESEARCH_TEXTDOMAIN) . '</option>';
                                echo $sort_options;
                                echo '</select></ul>';
                            }
                        }
                    }
                    echo "<ul {$ulid}>";
                    $classname = '';
                    $increment = 1;
                    echo $geodir_search_field_begin;
                    foreach ($terms as $term) {
                        $custom_term = is_array($term) && !empty($term) && isset($term['label']) ? true : false;
                        $option_label = $custom_term ? $term['label'] : false;
                        $option_value = $custom_term ? $term['value'] : false;
                        $optgroup = $custom_term && ($term['optgroup'] == 'start' || $term['optgroup'] == 'end') ? $term['optgroup'] : NULL;
                        if ($increment > $moreoption && !empty($moreoption)) {
                            $classname = 'class="more"';
                        }
                        if ($taxonomy_obj->field_site_type != 'taxonomy') {
                            if ($custom_term) {
                                $term = (object) $option_value;
                                $term->term_id = $option_value;
                                $term->name = $option_label;
                            } else {
                                $select_arr = array();
                                if (isset($term) && !empty($term)) {
                                    $select_arr = explode('/', $term);
                                }
                                $value = $term;
                                $term = (object) $term;
                                $term->term_id = $value;
                                $term->name = $value;
                                if (isset($select_arr[0]) && $select_arr[0] != '' && isset($select_arr[1]) && $select_arr[1] != '') {
                                    $term->term_id = $select_arr[1];
                                    $term->name = $select_arr[0];
                                }
                            }
                        }
                        $geodir_search_field_selected = false;
                        $geodir_search_field_selected_str = '';
                        $geodir_search_custom_value_str = '';
                        if (isset($_REQUEST['s' . $taxonomy_obj->site_htmlvar_name]) && is_array($_REQUEST['s' . $taxonomy_obj->site_htmlvar_name]) && in_array($term->term_id, $_REQUEST['s' . $taxonomy_obj->site_htmlvar_name])) {
                            $geodir_search_field_selected = true;
                        }
                        if (isset($_REQUEST['s' . $taxonomy_obj->site_htmlvar_name]) && $_REQUEST['s' . $taxonomy_obj->site_htmlvar_name] != '') {
                            $geodir_search_custom_value_str = isset($_REQUEST['s' . $taxonomy_obj->site_htmlvar_name]) ? stripslashes_deep($_REQUEST['s' . $taxonomy_obj->site_htmlvar_name]) : '';
                        }
                        switch ($taxonomy_obj->field_input_type) {
                            case 'CHECK':
                                if ($custom_term && $optgroup != '') {
                                    if ($optgroup == 'start') {
                                        echo '<li ' . $classname . '>' . $term->name . '</li>';
                                    }
                                } else {
                                    if ($geodir_search_field_selected) {
                                        $geodir_search_field_selected_str = ' checked="checked" ';
                                    }
                                    echo '<li ' . $classname . '><input type="checkbox" class="cat_check" name="s' . $taxonomy_obj->site_htmlvar_name . '[]" ' . $geodir_search_field_selected_str . ' value="' . $term->term_id . '" /> ' . $term->name . '</li>';
                                    $increment++;
                                }
                                break;
                            case 'RADIO':
                                if ($custom_term && $optgroup != '') {
                                    if ($optgroup == 'start') {
                                        echo '<li ' . $classname . '>' . $term->name . '</li>';
                                    }
                                } else {
                                    if ($geodir_search_field_selected) {
                                        $geodir_search_field_selected_str = ' checked="checked" ';
                                    }
                                    echo '<li ' . $classname . '><input type="radio" class="cat_check" name="s' . $taxonomy_obj->site_htmlvar_name . '[]" ' . $geodir_search_field_selected_str . ' value="' . $term->term_id . '" /> ' . $term->name . '</li>';
                                    $increment++;
                                }
                                break;
                            case 'SELECT':
                                if ($custom_term && $optgroup != '') {
                                    if ($optgroup == 'start') {
                                        echo '<optgroup label="' . esc_attr($term->name) . '">';
                                    } else {
                                        echo '</optgroup>';
                                    }
                                } else {
                                    if ($geodir_search_field_selected) {
                                        $geodir_search_field_selected_str = ' selected="selected" ';
                                    }
                                    echo '<option value="' . $term->term_id . '" ' . $geodir_search_field_selected_str . ' >' . $term->name . '</option>';
                                    $increment++;
                                }
                                break;
                            case 'LINK':
                                if ($custom_term && $optgroup != '') {
                                    if ($optgroup == 'start') {
                                        echo '<li ' . $classname . '> ' . $term->name . '</li>';
                                    }
                                } else {
                                    echo '<li ' . $classname . '><a href="' . home_url() . '?geodir_search=1&stype=' . $post_type . '&s=+&s' . $taxonomy_obj->site_htmlvar_name . '[]=' . $term->term_id . '">' . $term->name . '</a></li>';
                                    $increment++;
                                }
                                break;
                            case 'RANGE':
                                $search_starting_value_f = $taxonomy_obj->search_min_value;
                                $search_starting_value = $taxonomy_obj->search_min_value;
                                $search_maximum_value = $taxonomy_obj->search_max_value;
                                $search_diffrence = $taxonomy_obj->search_diff_value;
                                if (empty($search_starting_value)) {
                                    $search_starting_value = 10;
                                }
                                if (empty($search_maximum_value)) {
                                    $search_maximum_value = 50;
                                }
                                if (empty($search_diffrence)) {
                                    $search_diffrence = 10;
                                }
                                $first_search_text = $taxonomy_obj->first_search_text;
                                $last_search_text = $taxonomy_obj->last_search_text;
                                $first_search_value = $taxonomy_obj->first_search_value;
                                $first_search_text = $taxonomy_obj->first_search_text;
                                $last_search_text = $taxonomy_obj->last_search_text;
                                $first_search_value = $taxonomy_obj->first_search_value;
                                if (!empty($first_search_value)) {
                                    $search_starting_value = $first_search_value;
                                } else {
                                    $search_starting_value = $search_starting_value;
                                }
                                if (empty($first_search_text)) {
                                    $first_search_text = ' Less Than ';
                                }
                                if (empty($last_search_text)) {
                                    $last_search_text = ' More Than ';
                                }
                                $j = $search_starting_value_f;
                                $k = 0;
                                $set_maximum = 0;
                                $i = $search_starting_value_f;
                                $moreoption = '';
                                $expand_custom_value = $taxonomy_obj->expand_custom_value;
                                $expand_search = $taxonomy_obj->expand_search;
                                if (!empty($expand_search) && $expand_search > 0) {
                                    if ($expand_custom_value) {
                                        $moreoption = $expand_custom_value;
                                    } else {
                                        $moreoption = 5;
                                    }
                                }
                                switch ($taxonomy_obj->search_condition) {
                                    case 'SINGLE':
                                        $custom_value = isset($_REQUEST['s' . $taxonomy_obj->site_htmlvar_name]) ? stripslashes_deep($_REQUEST['s' . $taxonomy_obj->site_htmlvar_name]) : '';
                                        ?>
												<input type="text" class="cat_input" name="s<?php 
                                        echo $taxonomy_obj->site_htmlvar_name;
                                        ?>
"  value="<?php 
                                        echo esc_attr($custom_value);
                                        ?>
" /> <?php 
                                        break;
                                    case 'FROM':
                                        $smincustom_value = @$_REQUEST['smin' . $taxonomy_obj->site_htmlvar_name];
                                        $smaxcustom_value = @$_REQUEST['smax' . $taxonomy_obj->site_htmlvar_name];
                                        ?>
												<div class='from-to'>
													<input type='text' class='cat_input <?php 
                                        echo $taxonomy_obj->site_htmlvar_name;
                                        ?>
' placeholder='<?php 
                                        echo esc_attr(__('Start search value', GEODIRADVANCESEARCH_TEXTDOMAIN));
                                        ?>
' name='smin<?php 
                                        echo $taxonomy_obj->site_htmlvar_name;
                                        ?>
'  value='<?php 
                                        echo $smincustom_value;
                                        ?>
'>
													<input type='text' class='cat_input <?php 
                                        echo $taxonomy_obj->site_htmlvar_name;
                                        ?>
' placeholder='<?php 
                                        echo esc_attr(__('End search value', GEODIRADVANCESEARCH_TEXTDOMAIN));
                                        ?>
' name='smax<?php 
                                        echo $taxonomy_obj->site_htmlvar_name;
                                        ?>
' value='<?php 
                                        echo $smaxcustom_value;
                                        ?>
'>
												</div><?php 
                                        break;
                                    case 'LINK':
                                        $link_serach_value = @$_REQUEST['s' . $taxonomy_obj->site_htmlvar_name];
                                        $increment = 1;
                                        while ($i <= $search_maximum_value) {
                                            if ($k == 0) {
                                                $value = $search_starting_value . '-Less';
                                                ?>
  <li class=" <?php 
                                                if ($link_serach_value == $value) {
                                                    echo 'active';
                                                }
                                                if ($increment > $moreoption && !empty($moreoption)) {
                                                    echo 'more';
                                                }
                                                ?>
"><a href="<?php 
                                                echo home_url();
                                                ?>
?geodir_search=1&stype=<?php 
                                                echo $post_type;
                                                ?>
&s=+&s<?php 
                                                echo $taxonomy_obj->site_htmlvar_name;
                                                ?>
=<?php 
                                                echo $value;
                                                ?>
"><?php 
                                                echo $first_search_text . ' ' . $search_starting_value;
                                                ?>
</a></li>
													<?php 
                                                $k++;
                                            } else {
                                                if ($i <= $search_maximum_value) {
                                                    $value = $j . '-' . $i;
                                                    if ($search_diffrence == 1 && $taxonomy_obj->searching_range_mode == 1) {
                                                        $display_value = $j;
                                                        $value = $j . '-Less';
                                                    } else {
                                                        $display_value = '';
                                                    }
                                                    ?>
  <li class=" <?php 
                                                    if ($link_serach_value == $value) {
                                                        echo 'active';
                                                    }
                                                    if ($increment > $moreoption && !empty($moreoption)) {
                                                        echo 'more';
                                                    }
                                                    ?>
" ><a href="<?php 
                                                    echo home_url();
                                                    ?>
?geodir_search=1&stype=<?php 
                                                    echo $post_type;
                                                    ?>
&s=+&s<?php 
                                                    echo $taxonomy_obj->site_htmlvar_name;
                                                    ?>
=<?php 
                                                    echo $value;
                                                    ?>
"><?php 
                                                    if ($display_value) {
                                                        echo $display_value;
                                                    } else {
                                                        echo $value;
                                                    }
                                                    ?>
</a></li> 
														<?php 
                                                } else {
                                                    $value = $j . '-' . $i;
                                                    if ($search_diffrence == 1 && $taxonomy_obj->searching_range_mode == 1) {
                                                        $display_value = $j;
                                                        $value = $j . '-Less';
                                                    } else {
                                                        $display_value = '';
                                                    }
                                                    ?>
    <li class=" <?php 
                                                    if ($link_serach_value == $value) {
                                                        echo 'active';
                                                    }
                                                    if ($increment > $moreoption && !empty($moreoption)) {
                                                        echo 'more';
                                                    }
                                                    ?>
"><a href="<?php 
                                                    echo home_url();
                                                    ?>
?geodir_search=1&stype=<?php 
                                                    echo $post_type;
                                                    ?>
&s=+&s<?php 
                                                    echo $taxonomy_obj->site_htmlvar_name;
                                                    ?>
=<?php 
                                                    echo $value;
                                                    ?>
"><?php 
                                                    if ($display_value) {
                                                        echo $display_value;
                                                    } else {
                                                        echo $value;
                                                    }
                                                    ?>
</a>
					</li> 
															<?php 
                                                }
                                                $j = $i;
                                            }
                                            $i = $i + $search_diffrence;
                                            if ($i > $search_maximum_value) {
                                                if ($j != $search_maximum_value) {
                                                    $value = $j . '-' . $search_maximum_value;
                                                    ?>
   <li class=" <?php 
                                                    if ($link_serach_value == $value) {
                                                        echo 'active';
                                                    }
                                                    if ($increment > $moreoption && !empty($moreoption)) {
                                                        echo 'more';
                                                    }
                                                    ?>
" ><a href="<?php 
                                                    echo home_url();
                                                    ?>
?geodir_search=1&stype=<?php 
                                                    echo $post_type;
                                                    ?>
&s=+&s<?php 
                                                    echo $taxonomy_obj->site_htmlvar_name;
                                                    ?>
=<?php 
                                                    echo $value;
                                                    ?>
"><?php 
                                                    echo $value;
                                                    ?>
</a>
					</li><?php 
                                                }
                                                if ($search_diffrence == 1 && $taxonomy_obj->searching_range_mode == 1 && $j == $search_maximum_value) {
                                                    $display_value = $j;
                                                    $value = $j . '-Less';
                                                    ?>
    <li class=" <?php 
                                                    if ($link_serach_value == $value) {
                                                        echo 'active';
                                                    }
                                                    if ($increment > $moreoption && !empty($moreoption)) {
                                                        echo 'more';
                                                    }
                                                    ?>
"><a href="<?php 
                                                    echo home_url();
                                                    ?>
?geodir_search=1&stype=<?php 
                                                    echo $post_type;
                                                    ?>
&s=+&s<?php 
                                                    echo $taxonomy_obj->site_htmlvar_name;
                                                    ?>
=<?php 
                                                    echo $value;
                                                    ?>
"><?php 
                                                    if ($display_value) {
                                                        echo $display_value;
                                                    } else {
                                                        echo $value;
                                                    }
                                                    ?>
</a>
														</li> 
														<?php 
                                                }
                                                $value = $search_maximum_value . '-More';
                                                ?>
 
														  <li class=" <?php 
                                                if ($link_serach_value == $value) {
                                                    echo 'active';
                                                }
                                                if ($increment > $moreoption && !empty($moreoption)) {
                                                    echo 'more';
                                                }
                                                ?>
"><a href="<?php 
                                                echo home_url();
                                                ?>
?geodir_search=1&stype=<?php 
                                                echo $post_type;
                                                ?>
&s=+&s<?php 
                                                echo $taxonomy_obj->site_htmlvar_name;
                                                ?>
=<?php 
                                                echo $value;
                                                ?>
"><?php 
                                                echo $last_search_text . ' ' . $search_maximum_value;
                                                ?>
</a>
									  
														  </li>
														
														<?php 
                                            }
                                            $increment++;
                                        }
                                        break;
                                    case 'SELECT':
                                        $custom_search_value = @$_REQUEST['s' . $taxonomy_obj->site_htmlvar_name];
                                        ?>
												 <select name="s<?php 
                                        echo $taxonomy_obj->site_htmlvar_name;
                                        ?>
" class="cat_select" id="">
												<option value="">Select option</option><?php 
                                        if ($search_maximum_value > 0) {
                                            while ($i <= $search_maximum_value) {
                                                if ($k == 0) {
                                                    $value = $search_starting_value . '-Less';
                                                    ?>
  <option value="<?php 
                                                    echo esc_attr($value);
                                                    ?>
" <?php 
                                                    if ($custom_search_value == $value) {
                                                        echo 'selected="selected"';
                                                    }
                                                    ?>
 ><?php 
                                                    echo $first_search_text . ' ' . $search_starting_value;
                                                    ?>
</option>
													<?php 
                                                    $k++;
                                                } else {
                                                    if ($i <= $search_maximum_value) {
                                                        $value = $j . '-' . $i;
                                                        if ($search_diffrence == 1 && $taxonomy_obj->searching_range_mode == 1) {
                                                            $display_value = $j;
                                                            $value = $j . '-Less';
                                                        } else {
                                                            $display_value = '';
                                                        }
                                                        ?>
  <option value="<?php 
                                                        echo esc_attr($value);
                                                        ?>
" <?php 
                                                        if ($custom_search_value == $value) {
                                                            echo 'selected="selected"';
                                                        }
                                                        ?>
 ><?php 
                                                        if ($display_value) {
                                                            echo $display_value;
                                                        } else {
                                                            echo $value;
                                                        }
                                                        ?>
</option>
														<?php 
                                                    } else {
                                                        $value = $j . '-' . $i;
                                                        if ($search_diffrence == 1 && $taxonomy_obj->searching_range_mode == 1) {
                                                            $display_value = $j;
                                                            $value = $j . '-Less';
                                                        } else {
                                                            $display_value = '';
                                                        }
                                                        ?>
  <option value="<?php 
                                                        echo esc_attr($value);
                                                        ?>
" <?php 
                                                        if ($custom_search_value == $value) {
                                                            echo 'selected="selected"';
                                                        }
                                                        ?>
 ><?php 
                                                        if ($display_value) {
                                                            echo $display_value;
                                                        } else {
                                                            echo $value;
                                                        }
                                                        ?>
</option>
														<?php 
                                                    }
                                                    $j = $i;
                                                }
                                                $i = $i + $search_diffrence;
                                                if ($i > $search_maximum_value) {
                                                    if ($j != $search_maximum_value) {
                                                        $value = $j . '-' . $search_maximum_value;
                                                        ?>
  <option value="<?php 
                                                        echo esc_attr($value);
                                                        ?>
" <?php 
                                                        if ($custom_search_value == $value) {
                                                            echo 'selected="selected"';
                                                        }
                                                        ?>
 ><?php 
                                                        echo $value;
                                                        ?>
</option>
													<?php 
                                                    }
                                                    if ($search_diffrence == 1 && $taxonomy_obj->searching_range_mode == 1 && $j == $search_maximum_value) {
                                                        $display_value = $j;
                                                        $value = $j . '-Less';
                                                        ?>
 <option value="<?php 
                                                        echo esc_attr($value);
                                                        ?>
" <?php 
                                                        if ($custom_search_value == $value) {
                                                            echo 'selected="selected"';
                                                        }
                                                        ?>
 ><?php 
                                                        if ($display_value) {
                                                            echo $display_value;
                                                        } else {
                                                            echo $value;
                                                        }
                                                        ?>
</option>
												<?php 
                                                    }
                                                    $value = $search_maximum_value . '-More';
                                                    ?>
  <option value="<?php 
                                                    echo esc_attr($value);
                                                    ?>
" <?php 
                                                    if ($custom_search_value == $value) {
                                                        echo 'selected="selected"';
                                                    }
                                                    ?>
 ><?php 
                                                    echo $last_search_text . ' ' . $search_maximum_value;
                                                    ?>
</option>
													<?php 
                                                }
                                            }
                                        }
                                        ?>
                                            </select>
                                            <?php 
                                        break;
                                    case 'RADIO':
                                        $uom = get_option('geodir_search_dist_1');
                                        $dist_dif = $search_diffrence;
                                        for ($i = $dist_dif; $i <= $search_maximum_value; $i = $i + $dist_dif) {
                                            $checked = '';
                                            if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] == $i) {
                                                $checked = 'checked="checked"';
                                            }
                                            if ($increment > $moreoption && !empty($moreoption)) {
                                                $classname = 'class="more"';
                                            }
                                            echo '<li ' . $classname . '><input type="radio" class="cat_check" name="sdist" ' . $checked . ' value="' . $i . '" />' . __('Within', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $i . ' ' . __($uom, GEODIRECTORY_TEXTDOMAIN) . '</li>';
                                            $increment++;
                                        }
                                        //echo "<pre>"; print_r($taxonomy_obj);
                                        break;
                                }
                                #############Range search###############
                                break;
                            case "DATE":
                                if ($taxonomy_obj->search_condition == 'SINGLE' && $taxonomy_obj->site_htmlvar_name != 'event') {
                                    $custom_value = isset($_REQUEST['s' . $taxonomy_obj->site_htmlvar_name]) ? stripslashes_deep($_REQUEST['s' . $taxonomy_obj->site_htmlvar_name]) : '';
                                    ?>
							<input  type="text" class="cat_input <?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
" name="s<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
" id="s<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
" value="<?php 
                                    echo esc_attr($custom_value);
                                    ?>
" />     <?php 
                                } elseif ($taxonomy_obj->search_condition == 'FROM' && $taxonomy_obj->site_htmlvar_name != 'event') {
                                    $smincustom_value = @$_REQUEST['smin' . $taxonomy_obj->site_htmlvar_name];
                                    $smaxcustom_value = @$_REQUEST['smax' . $taxonomy_obj->site_htmlvar_name];
                                    ?>
							<div class='from-to'>  
							<input  type='text' class='cat_input' placeholder='<?php 
                                    echo esc_attr(__('Start search value', GEODIRADVANCESEARCH_TEXTDOMAIN));
                                    ?>
' id="smin<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
" name='smin<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
'  value='<?php 
                                    echo $smincustom_value;
                                    ?>
'>       
							<input  type='text' class='cat_input' placeholder='<?php 
                                    echo esc_attr(__('End search value', GEODIRADVANCESEARCH_TEXTDOMAIN));
                                    ?>
' id="smax<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
" name='smax<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
' value='<?php 
                                    echo $smaxcustom_value;
                                    ?>
'>        
							</div><?php 
                                } elseif ($taxonomy_obj->search_condition == 'SINGLE' && $taxonomy_obj->site_htmlvar_name == 'event') {
                                    $smincustom_value = @$_REQUEST[$taxonomy_obj->site_htmlvar_name . '_start'];
                                    ?>
							<div class='from-to'>         
							<input type="text" value="<?php 
                                    echo esc_attr($smincustom_value);
                                    ?>
" placeholder='' class='cat_input' id="<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
_start" name="<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
_start" field_type="text" />  
							</div>  
							<?php 
                                } elseif ($taxonomy_obj->search_condition == 'FROM' && $taxonomy_obj->site_htmlvar_name == 'event') {
                                    $smincustom_value = @$_REQUEST[$taxonomy_obj->site_htmlvar_name . '_start'];
                                    $smaxcustom_value = @$_REQUEST[$taxonomy_obj->site_htmlvar_name . '_end'];
                                    ?>
							
							<div class='from-to'>         
							<input type="text" value="<?php 
                                    echo esc_attr($smincustom_value);
                                    ?>
" placeholder='<?php 
                                    echo esc_attr(__('Start search date', GEODIRADVANCESEARCH_TEXTDOMAIN));
                                    ?>
' class='cat_input' id="<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
_start" name="<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
_start" field_type="text" />   
							<input type="text" value="<?php 
                                    echo esc_attr($smaxcustom_value);
                                    ?>
" placeholder='<?php 
                                    echo esc_attr(__('End search date', GEODIRADVANCESEARCH_TEXTDOMAIN));
                                    ?>
' class='cat_input' id="<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
_end" name="<?php 
                                    echo $taxonomy_obj->site_htmlvar_name;
                                    ?>
_end" field_type="text" />    
							</div> 
							<?php 
                                }
                                break;
                            default:
                                if (isset($taxonomy_obj->field_site_type) && $taxonomy_obj->field_site_type == 'checkbox') {
                                    $checked = '';
                                    if ($geodir_search_custom_value_str == '1') {
                                        $checked = 'checked="checked"';
                                    }
                                    echo '<li><input ' . $checked . ' type="' . $taxonomy_obj->field_site_type . '" class="cat_input" name="s' . $taxonomy_obj->site_htmlvar_name . '"  value="1" /> ' . __('Yes', GEODIRADVANCESEARCH_TEXTDOMAIN) . '</li>';
                                } else {
                                    echo '<li><input type="' . $taxonomy_obj->field_input_type . '" class="cat_input" name="s' . $taxonomy_obj->site_htmlvar_name . '"  value="' . esc_attr($geodir_search_custom_value_str) . '" /></li>';
                                }
                        }
                    }
                    echo $geodir_search_field_end;
                    if ($increment - 1 > $moreoption && !empty($moreoption) && $moreoption > 0) {
                        echo '<li class="bordernone"><span class="expandmore" onclick="javascript:geodir_search_expandmore(this);"> ' . __('More', GEODIRADVANCESEARCH_TEXTDOMAIN) . '</span></li>';
                    }
                    echo '</ul>';
                    if (!empty($taxonomy_obj->field_desc)) {
                        echo "<ul><li>{$taxonomy_obj->field_desc}</li></ul>";
                    }
                }
                echo '</div>';
            }
        }
    }
    echo $html = ob_get_clean();
}
/**
 * Details page tab custom fields.
 *
 * @since 1.0.0
 * @since 1.5.7 Custom fields option values added to db translation.
 *              Changes to display url fields title.
 * @package GeoDirectory
 * @global object $post The current post object.
 * @param array $tabs_arr Tabs array {@see geodir_detail_page_tab_headings_change()}.
 * @return array Modified tabs array.
 */
function geodir_detail_page_custom_field_tab($tabs_arr)
{
    global $post;
    $post_type = geodir_get_current_posttype();
    $all_postypes = geodir_get_posttypes();
    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
        $package_info = array();
        $package_info = geodir_post_package_info($package_info, $post);
        $post_package_id = $package_info->pid;
        $fields_location = 'detail';
        $custom_fields = geodir_post_custom_fields($post_package_id, 'default', $post_type, $fields_location);
        if (!empty($custom_fields)) {
            $parse_custom_fields = array();
            foreach ($custom_fields as $field) {
                $field = stripslashes_deep($field);
                // strip slashes
                $type = $field;
                $field_name = $field['htmlvar_name'];
                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
                    $post->{$field_name} = $_REQUEST[$field_name];
                }
                if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && (isset($post->{$field_name}) && $post->{$field_name} != '' || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
                    if ($type['type'] == 'datepicker' && ($post->{$type}['htmlvar_name'] == '' || $post->{$type}['htmlvar_name'] == '0000-00-00')) {
                        continue;
                    }
                    $parse_custom_fields[] = $field;
                }
            }
            $custom_fields = $parse_custom_fields;
        }
        if (!empty($custom_fields)) {
            $field_set_start = 0;
            $fieldset_count = 0;
            $fieldset = '';
            $total_fields = count($custom_fields);
            $count_field = 0;
            $fieldset_arr = array();
            $i = 0;
            $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
            foreach ($custom_fields as $field) {
                $count_field++;
                $field_name = $field['htmlvar_name'];
                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
                    $post->{$field_name} = $_REQUEST[$field_name];
                }
                if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && (isset($post->{$field_name}) && $post->{$field_name} != '' || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
                    $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
                    $site_title = trim($field['site_title']);
                    $type = $field;
                    $html = '';
                    $html_var = $field_name;
                    $field_icon = '';
                    $variables_array = array();
                    if ($type['type'] == 'datepicker' && ($post->{$type}['htmlvar_name'] == '' || $post->{$type}['htmlvar_name'] == '0000-00-00')) {
                        continue;
                    }
                    if ($type['type'] != 'fieldset') {
                        $i++;
                        $variables_array['post_id'] = $post->ID;
                        $variables_array['label'] = __($type['site_title'], 'geodirectory');
                        $variables_array['value'] = '';
                        $variables_array['value'] = $post->{$type}['htmlvar_name'];
                    }
                    if (strpos($type['field_icon'], 'http') !== false) {
                        $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
                    } elseif (strpos($type['field_icon'], 'fa fa-') !== false) {
                        $field_icon = '<i class="' . $type['field_icon'] . '"></i>';
                    }
                    switch ($type['type']) {
                        case 'fieldset':
                            $i = 0;
                            $fieldset_count++;
                            $field_set_start = 1;
                            $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
                            $fieldset_arr[$fieldset_count]['label'] = $label;
                            break;
                        case 'url':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                if ($type['name'] == 'geodir_facebook') {
                                    $field_icon_af = '<i class="fa fa-facebook-square"></i>';
                                } elseif ($type['name'] == 'geodir_twitter') {
                                    $field_icon_af = '<i class="fa fa-twitter-square"></i>';
                                } else {
                                    $field_icon_af = '<i class="fa fa-link"></i>';
                                }
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $a_url = geodir_parse_custom_field_url($post->{$type}['htmlvar_name']);
                            $website = !empty($a_url['url']) ? $a_url['url'] : '';
                            $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title'];
                            $title = $title != '' ? __(stripslashes($title), 'geodirectory') : '';
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            // all search engines that use the nofollow value exclude links that use it from their ranking calculation
                            $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . ' <a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>';
                            break;
                        case 'phone':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '<i class="fa fa-phone"></i>';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>';
                            break;
                        case 'time':
                            $value = '';
                            if ($post->{$type}['htmlvar_name'] != '') {
                                //$value = date('h:i',strtotime($post->$type['htmlvar_name']));
                                $value = date(get_option('time_format'), strtotime($post->{$type}['htmlvar_name']));
                            }
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '<i class="fa fa-clock-o"></i>';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . stripslashes($value) . '</div>';
                            break;
                        case 'datepicker':
                            $date_format = geodir_default_date_format();
                            if ($type['extra_fields'] != '') {
                                $date_format = unserialize($type['extra_fields']);
                                $date_format = $date_format['date_format'];
                            }
                            $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy');
                            //jQuery UI datepicker format
                            $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y');
                            //PHP date format
                            $date_format = str_replace($search, $replace, $date_format);
                            $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type}['htmlvar_name']) : $post->{$type}['htmlvar_name'];
                            // PHP doesn't work well with dd/mm/yyyy format
                            $value = '';
                            if ($post->{$type}['htmlvar_name'] != '') {
                                $value = date($date_format, strtotime($post_htmlvar_value));
                            }
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '<i class="fa fa-calendar"></i>';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . $value . '</div>';
                            break;
                        case 'text':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>';
                            break;
                        case 'radio':
                            if ($post->{$type}['htmlvar_name'] != '') {
                                if ($post->{$type}['htmlvar_name'] == 'f' || $post->{$type}['htmlvar_name'] == '0') {
                                    $html_val = __('No', 'geodirectory');
                                } else {
                                    if ($post->{$type}['htmlvar_name'] == 't' || $post->{$type}['htmlvar_name'] == '1') {
                                        $html_val = __('Yes', 'geodirectory');
                                    } else {
                                        $html_val = __($post->{$type}['htmlvar_name'], 'geodirectory');
                                        if (!empty($type['option_values'])) {
                                            $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true);
                                            if (!empty($cf_option_values)) {
                                                foreach ($cf_option_values as $cf_option_value) {
                                                    if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type}['htmlvar_name']) {
                                                        $html_val = $cf_option_value['label'];
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (strpos($field_icon, 'http') !== false) {
                                    $field_icon_af = '';
                                } else {
                                    if ($field_icon == '') {
                                        $field_icon_af = '';
                                    } else {
                                        $field_icon_af = $field_icon;
                                        $field_icon = '';
                                    }
                                }
                                $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                                $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af;
                                if ($field_set_start == 1 && $site_title != '') {
                                    $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                                }
                                $html .= ' </span>' . $html_val . '</div>';
                            }
                            break;
                        case 'checkbox':
                            $html_var = $type['htmlvar_name'];
                            $html_val = $type['htmlvar_name'];
                            if ((int) $post->{$html_var} == 1) {
                                if ($post->{$type}['htmlvar_name'] == '1') {
                                    $html_val = __('Yes', 'geodirectory');
                                } else {
                                    $html_val = __('No', 'geodirectory');
                                }
                                if (strpos($field_icon, 'http') !== false) {
                                    $field_icon_af = '';
                                } else {
                                    if ($field_icon == '') {
                                        $field_icon_af = '';
                                    } else {
                                        $field_icon_af = $field_icon;
                                        $field_icon = '';
                                    }
                                }
                                $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                                $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af;
                                if ($field_set_start == 1 && $site_title != '') {
                                    $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                                }
                                $html .= ' </span>' . $html_val . '</div>';
                            }
                            break;
                        case 'select':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $field_value = __($post->{$type}['htmlvar_name'], 'geodirectory');
                            if (!empty($type['option_values'])) {
                                $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true);
                                if (!empty($cf_option_values)) {
                                    foreach ($cf_option_values as $cf_option_value) {
                                        if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type}['htmlvar_name']) {
                                            $field_value = $cf_option_value['label'];
                                        }
                                    }
                                }
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . $field_value . '</div>';
                            break;
                        case 'multiselect':
                            if (is_array($post->{$type}['htmlvar_name'])) {
                                $post->{$type}['htmlvar_name'] = implode(', ', $post->{$type}['htmlvar_name']);
                            }
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $field_values = explode(',', trim($post->{$type}['htmlvar_name'], ","));
                            $option_values = array();
                            if (!empty($type['option_values'])) {
                                $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true);
                                if (!empty($cf_option_values)) {
                                    foreach ($cf_option_values as $cf_option_value) {
                                        if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
                                            $option_values[] = $cf_option_value['label'];
                                        }
                                    }
                                }
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>';
                            if (count($option_values) > 1) {
                                $html .= '<ul>';
                                foreach ($option_values as $val) {
                                    $html .= '<li>' . $val . '</li>';
                                }
                                $html .= '</ul>';
                            } else {
                                $html .= $post->{$type}['htmlvar_name'];
                            }
                            $html .= '</div>';
                            break;
                        case 'email':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '<i class="fa fa-envelope"></i>';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>';
                            break;
                        case 'textarea':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= '</span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>';
                            break;
                        case 'html':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>';
                            break;
                        case 'file':
                            $html_var = $type['htmlvar_name'];
                            if (!empty($post->{$type}['htmlvar_name'])) {
                                $files = explode(",", $post->{$type}['htmlvar_name']);
                                if (!empty($files)) {
                                    $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL;
                                    $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : '';
                                    $file_paths = '';
                                    foreach ($files as $file) {
                                        if (!empty($file)) {
                                            $filetype = wp_check_filetype($file);
                                            $image_name_arr = explode('/', $file);
                                            $curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
                                            $filename = end($image_name_arr);
                                            $img_name_arr = explode('.', $filename);
                                            $arr_file_type = wp_check_filetype($filename);
                                            if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
                                                continue;
                                            }
                                            $uploaded_file_type = $arr_file_type['type'];
                                            $uploaded_file_ext = $arr_file_type['ext'];
                                            if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
                                                continue;
                                                // Invalid file type.
                                            }
                                            //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
                                            $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
                                            // If the uploaded file is image
                                            if (in_array($uploaded_file_type, $image_file_types)) {
                                                $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">';
                                                $file_paths .= '<a href="' . $file . '">';
                                                $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
                                                $file_paths .= '</a>';
                                                $file_paths .= '</div>';
                                            } else {
                                                $ext_path = '_' . $html_var . '_';
                                                $filename = explode($ext_path, $filename);
                                                $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>';
                                            }
                                        }
                                    }
                                    if (strpos($field_icon, 'http') !== false) {
                                        $field_icon_af = '';
                                    } else {
                                        if ($field_icon == '') {
                                            $field_icon_af = '';
                                        } else {
                                            $field_icon_af = $field_icon;
                                            $field_icon = '';
                                        }
                                    }
                                    $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                                    $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . ' geodir-custom-file-box" style="clear:both;"><span class="geodir-i-file" style="display:inline-block;vertical-align:top;padding-right:14px;' . $field_icon . '">' . $field_icon_af;
                                    if ($field_set_start == 1 && $site_title != '') {
                                        $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                                    }
                                    $html .= ' </span>' . $file_paths . '</div>';
                                }
                            }
                            break;
                    }
                    /**
                     * Filter custom field output in tab.
                     *
                     * @since 1.5.6
                     *
                     * @param string $html_var The HTML variable name for the field.
                     * @param string $html Custom field unfiltered HTML.
                     * @param array $variables_array Custom field variables array.
                     */
                    $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
                    if ($field_set_start == 1) {
                        $add_html = false;
                        if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
                            if ($fieldset != '') {
                                $add_html = true;
                                $label = $fieldset_arr[$fieldset_count - 1]['label'];
                                $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
                            }
                            $fieldset_html = $fieldset;
                            $fieldset = '';
                        } else {
                            $fieldset .= $html;
                            if ($total_fields == $count_field && $fieldset != '') {
                                $add_html = true;
                                $label = $fieldset_arr[$fieldset_count]['label'];
                                $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
                                $fieldset_html = $fieldset;
                            }
                        }
                        if ($add_html) {
                            $tabs_arr[$htmlvar_name] = array('heading_text' => __($label, 'geodirectory'), 'is_active_tab' => false, 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), 'tab_content' => '<div class="geodir-company_info field-group">' . $fieldset_html . '</html>');
                        }
                    } else {
                        if ($html != '') {
                            $tabs_arr[$field['htmlvar_name']] = array('heading_text' => __($label, 'geodirectory'), 'is_active_tab' => false, 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']), 'tab_content' => $html);
                        }
                    }
                }
            }
        }
    }
    return $tabs_arr;
}
Example #3
0
/**
 * Displays custom fields html.
 *
 * @since 1.0.0
 * @since 1.5.2 Added TERRAIN map type.
 * @package GeoDirectory
 * @global object $wpdb WordPress Database object.
 * @global object $post The current post object.
 * @global array $geodir_addon_list List of active GeoDirectory extensions.
 * @param int|string $package_id The package ID.
 * @param string $default Optional. When set to "default" it will display only default fields.
 * @param string $post_type Optional. The wordpress post type.
 */
function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place')
{
    global $is_default, $mapzoom;
    $show_editors = array();
    $listing_type = $post_type;
    $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
    foreach ($custom_fields as $key => $val) {
        $val = stripslashes_deep($val);
        // strip slashes from labels
        $name = $val['name'];
        $site_title = $val['site_title'];
        $type = $val['type'];
        $admin_desc = $val['desc'];
        $option_values = $val['option_values'];
        $is_required = $val['is_required'];
        $is_default = $val['is_default'];
        $is_admin = $val['is_admin'];
        $required_msg = $val['required_msg'];
        $extra_fields = unserialize($val['extra_fields']);
        $value = '';
        /* field available to site admin only for edit */
        $for_admin_use = isset($val['for_admin_use']) && (int) $val['for_admin_use'] == 1 ? true : false;
        if ($for_admin_use && !is_super_admin()) {
            continue;
        }
        if (is_admin()) {
            global $post;
            if (isset($_REQUEST['post'])) {
                $_REQUEST['pid'] = $_REQUEST['post'];
            }
        }
        if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && isset($_SESSION['listing'])) {
            $post = unserialize($_SESSION['listing']);
            $value = isset($post[$name]) ? $post[$name] : '';
        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
            $value = geodir_get_post_meta($_REQUEST['pid'], $name, true);
        } else {
            if ($value == '') {
                $value = $val['default'];
            }
        }
        /**
         * Called before the custom fields info is output for submitting a post.
         *
         * Used dynamic hook type geodir_before_custom_form_field_$name.
         *
         * @since 1.0.0
         * @param string $listing_type The post post type.
         * @param int $package_id The price package ID for the post.
         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
         * @see 'geodir_after_custom_form_field_$name'
         */
        do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
        if ($type == 'fieldset') {
            ?>
<h5><?php 
            echo $site_title;
            ?>
            <?php 
            if ($admin_desc != '') {
                echo '<small>( ' . $admin_desc . ' )</small>';
            }
            ?>
            </h5><?php 
        } elseif ($type == 'address') {
            $prefix = $name . '_';
            $site_title != '' ? $address_title = $site_title : ($address_title = ucwords($prefix . ' address'));
            $extra_fields['zip_lable'] != '' ? $zip_title = $extra_fields['zip_lable'] : ($zip_title = ucwords($prefix . ' zip/post code '));
            $extra_fields['map_lable'] != '' ? $map_title = $extra_fields['map_lable'] : ($map_title = ucwords('set address on map'));
            $extra_fields['mapview_lable'] != '' ? $mapview_title = $extra_fields['mapview_lable'] : ($mapview_title = ucwords($prefix . ' mapview'));
            $address = '';
            $zip = '';
            $mapview = '';
            $mapzoom = '';
            $lat = '';
            $lng = '';
            if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && isset($_SESSION['listing'])) {
                $post = unserialize($_SESSION['listing']);
                $address = $post[$prefix . 'address'];
                $zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : '';
                $lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : '';
                $lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : '';
                $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : '';
                $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : '';
            } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && ($post_info = geodir_get_post_info($_REQUEST['pid']))) {
                $post_info = (array) $post_info;
                $address = $post_info[$prefix . 'address'];
                $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : '';
                $lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : '';
                $lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : '';
                $mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : '';
                $mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : '';
            }
            $location = geodir_get_default_location();
            if (empty($city)) {
                $city = isset($location->city) ? $location->city : '';
            }
            if (empty($region)) {
                $region = isset($location->region) ? $location->region : '';
            }
            if (empty($country)) {
                $country = isset($location->country) ? $location->country : '';
            }
            $lat_lng_blank = false;
            if (empty($lat) && empty($lng)) {
                $lat_lng_blank = true;
            }
            if (empty($lat)) {
                $lat = isset($location->city_latitude) ? $location->city_latitude : '';
            }
            if (empty($lng)) {
                $lng = isset($location->city_longitude) ? $location->city_longitude : '';
            }
            /**
             * Filter the default latitude.
             *
             * @since 1.0.0
             *
             * @param float $lat Default latitude.
             * @param bool $is_admin For admin use only?.
             */
            $lat = apply_filters('geodir_default_latitude', $lat, $is_admin);
            /**
             * Filter the default longitude.
             *
             * @since 1.0.0
             *
             * @param float $lat Default longitude.
             * @param bool $is_admin For admin use only?.
             */
            $lng = apply_filters('geodir_default_longitude', $lng, $is_admin);
            ?>

            <div id="geodir_<?php 
            echo $prefix . 'address';
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            _e($address_title, 'geodirectory');
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input type="text" field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $prefix . 'address';
            ?>
"
                       id="<?php 
            echo $prefix . 'address';
            ?>
" class="geodir_textfield"
                       value="<?php 
            echo esc_attr(stripslashes($address));
            ?>
"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>


            <?php 
            /**
             * Called after the address input on the add listings.
             *
             * This is used by the location manage to add further locations info etc.
             *
             * @since 1.0.0
             * @param array $val The array of setting for the custom field. {@see geodir_custom_field_save()}.
             */
            do_action('geodir_address_extra_listing_fields', $val);
            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
                ?>

                <div id="geodir_<?php 
                echo $prefix . 'zip';
                ?>
_row"
                     class="<?php 
                /*if($is_required) echo 'required_field';*/
                ?>
 geodir_form_row clearfix">
                    <label>
                        <?php 
                _e($zip_title, 'geodirectory');
                ?>
                        <?php 
                /*if($is_required) echo '<span>*</span>';*/
                ?>
                    </label>
                    <input type="text" field_type="<?php 
                echo $type;
                ?>
" name="<?php 
                echo $prefix . 'zip';
                ?>
"
                           id="<?php 
                echo $prefix . 'zip';
                ?>
" class="geodir_textfield autofill"
                           value="<?php 
                echo esc_attr(stripslashes($zip));
                ?>
"/>
                    <?php 
                /*if($is_required) {?>
                		<span class="geodir_message_error"><?php echo _e($required_msg,'geodirectory');?></span>
                		<?php }*/
                ?>
                </div>
            <?php 
            }
            ?>

            <?php 
            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
                ?>

                <div id="geodir_<?php 
                echo $prefix . 'map';
                ?>
_row" class="geodir_form_row clearfix">
                    <?php 
                /**
                 * Contains add listing page map functions.
                 *
                 * @since 1.0.0
                 */
                include geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php";
                if ($lat_lng_blank) {
                    $lat = '';
                    $lng = '';
                }
                ?>
                    <span class="geodir_message_note"><?php 
                echo GET_MAP_MSG;
                ?>
</span>
                </div>
                <?php 
                /* show lat lng */
                $style_latlng = isset($extra_fields['show_latlng']) && $extra_fields['show_latlng'] || is_admin() ? '' : 'style="display:none"';
                ?>
                <div id="geodir_<?php 
                echo $prefix . 'latitude';
                ?>
_row"
                     class="<?php 
                if ($is_required) {
                    echo 'required_field';
                }
                ?>
 geodir_form_row clearfix" <?php 
                echo $style_latlng;
                ?>
>
                    <label>
                        <?php 
                echo PLACE_ADDRESS_LAT;
                ?>
                        <?php 
                if ($is_required) {
                    echo '<span>*</span>';
                }
                ?>
                    </label>
                    <input type="text" field_type="<?php 
                echo $type;
                ?>
" name="<?php 
                echo $prefix . 'latitude';
                ?>
"
                           id="<?php 
                echo $prefix . 'latitude';
                ?>
" class="geodir_textfield"
                           value="<?php 
                echo esc_attr(stripslashes($lat));
                ?>
" size="25"/>
                    <span class="geodir_message_note"><?php 
                echo GET_LATITUDE_MSG;
                ?>
</span>
                    <?php 
                if ($is_required) {
                    ?>
                        <span class="geodir_message_error"><?php 
                    _e($required_msg, 'geodirectory');
                    ?>
</span>
                    <?php 
                }
                ?>
                </div>

                <div id="geodir_<?php 
                echo $prefix . 'longitude';
                ?>
_row"
                     class="<?php 
                if ($is_required) {
                    echo 'required_field';
                }
                ?>
 geodir_form_row clearfix" <?php 
                echo $style_latlng;
                ?>
>
                    <label>
                        <?php 
                echo PLACE_ADDRESS_LNG;
                ?>
                        <?php 
                if ($is_required) {
                    echo '<span>*</span>';
                }
                ?>
                    </label>
                    <input type="text" field_type="<?php 
                echo $type;
                ?>
" name="<?php 
                echo $prefix . 'longitude';
                ?>
"
                           id="<?php 
                echo $prefix . 'longitude';
                ?>
" class="geodir_textfield"
                           value="<?php 
                echo esc_attr(stripslashes($lng));
                ?>
" size="25"/>
                    <span class="geodir_message_note"><?php 
                echo GET_LOGNGITUDE_MSG;
                ?>
</span>
                    <?php 
                if ($is_required) {
                    ?>
                        <span class="geodir_message_error"><?php 
                    _e($required_msg, 'geodirectory');
                    ?>
</span>
                    <?php 
                }
                ?>
                </div>
            <?php 
            }
            ?>

            <?php 
            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
                ?>
                <div id="geodir_<?php 
                echo $prefix . 'mapview';
                ?>
_row" class="geodir_form_row clearfix ">
                    <label><?php 
                _e($mapview_title, 'geodirectory');
                ?>
</label>


                    <span class="geodir_user_define"><input field_type="<?php 
                echo $type;
                ?>
" type="radio"
                                                            class="gd-checkbox"
                                                            name="<?php 
                echo $prefix . 'mapview';
                ?>
"
                                                            id="<?php 
                echo $prefix . 'mapview';
                ?>
" <?php 
                if ($mapview == 'ROADMAP' || $mapview == '') {
                    echo 'checked="checked"';
                }
                ?>
  value="ROADMAP" size="25"/> <?php 
                _e('Default Map', 'geodirectory');
                ?>
</span>
                    <span class="geodir_user_define"> <input field_type="<?php 
                echo $type;
                ?>
" type="radio"
                                                             class="gd-checkbox"
                                                             name="<?php 
                echo $prefix . 'mapview';
                ?>
"
                                                             id="map_view1" <?php 
                if ($mapview == 'SATELLITE') {
                    echo 'checked="checked"';
                }
                ?>
 value="SATELLITE" size="25"/> <?php 
                _e('Satellite Map', 'geodirectory');
                ?>
</span>

                    <span class="geodir_user_define"><input field_type="<?php 
                echo $type;
                ?>
" type="radio"
                                                            class="gd-checkbox"
                                                            name="<?php 
                echo $prefix . 'mapview';
                ?>
"
                                                            id="map_view2" <?php 
                if ($mapview == 'HYBRID') {
                    echo 'checked="checked"';
                }
                ?>
  value="HYBRID" size="25"/> <?php 
                _e('Hybrid Map', 'geodirectory');
                ?>
</span>
					<span class="geodir_user_define"><input field_type="<?php 
                echo $type;
                ?>
" type="radio"
                                                            class="gd-checkbox"
                                                            name="<?php 
                echo $prefix . 'mapview';
                ?>
"
                                                            id="map_view3" <?php 
                if ($mapview == 'TERRAIN') {
                    echo 'checked="checked"';
                }
                ?>
  value="TERRAIN" size="25"/> <?php 
                _e('Terrain Map', 'geodirectory');
                ?>
</span>


                </div>
            <?php 
            }
            ?>

            <?php 
            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
                ?>
                <input type="hidden" value="<?php 
                if (isset($mapzoom)) {
                    echo esc_attr($mapzoom);
                }
                ?>
" name="<?php 
                echo $prefix . 'mapzoom';
                ?>
" id="<?php 
                echo $prefix . 'mapzoom';
                ?>
"/>
            <?php 
            }
            ?>
        <?php 
        } elseif ($type == 'text') {
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                       value="<?php 
            echo esc_attr(stripslashes($value));
            ?>
" type="text" class="geodir_textfield"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'email') {
            if ($value == $val['default']) {
                $value = '';
            }
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                       value="<?php 
            echo esc_attr(stripslashes($value));
            ?>
" type="text" class="geodir_textfield"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'phone') {
            if ($value == $val['default']) {
                $value = '';
            }
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                       value="<?php 
            echo esc_attr(stripslashes($value));
            ?>
" type="text" class="geodir_textfield"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'url') {
            if ($value == $val['default']) {
                $value = '';
            }
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                       value="<?php 
            echo esc_attr(stripslashes($value));
            ?>
" type="text" class="geodir_textfield"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'radio') {
            ?>
            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>

                <?php 
            if ($option_values) {
                $option_values_arr = explode(',', $option_values);
                for ($i = 0; $i < count($option_values_arr); $i++) {
                    if (strstr($option_values_arr[$i], "/")) {
                        $radio_attr = explode("/", $option_values_arr[$i]);
                        $radio_lable = ucfirst($radio_attr[0]);
                        $radio_value = $radio_attr[1];
                    } else {
                        $radio_lable = ucfirst($option_values_arr[$i]);
                        $radio_value = $option_values_arr[$i];
                    }
                    ?>

                        <input name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
" <?php 
                    if ($radio_value == $value) {
                        echo 'checked="checked"';
                    }
                    ?>
  value="<?php 
                    echo $radio_value;
                    ?>
" class="gd-checkbox" field_type="<?php 
                    echo $type;
                    ?>
"
                               type="radio"  /><?php 
                    _e($radio_lable);
                    ?>

                    <?php 
                }
            }
            ?>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'checkbox') {
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <?php 
            if ($value != '1') {
                $value = '0';
            }
            ?>
                <input type="hidden" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
" value="<?php 
            echo esc_attr($value);
            ?>
"/>
                <input  <?php 
            if ($value == '1') {
                echo 'checked="checked"';
            }
            ?>
  value="1" class="gd-checkbox" field_type="<?php 
            echo $type;
            ?>
" type="checkbox"
                     onchange="if(this.checked){jQuery('#<?php 
            echo $name;
            ?>
').val('1');} else{ jQuery('#<?php 
            echo $name;
            ?>
').val('0');}"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'textarea') {
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label><?php 
            if (is_array($extra_fields) && in_array('1', $extra_fields)) {
                $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
                ?>

                <div class="editor" field_id="<?php 
                echo $name;
                ?>
" field_type="editor">
                    <?php 
                wp_editor(stripslashes($value), $name, $editor_settings);
                ?>
                    </div><?php 
            } else {
                ?>
<textarea field_type="<?php 
                echo $type;
                ?>
" class="geodir_textarea" name="<?php 
                echo $name;
                ?>
"
                                id="<?php 
                echo $name;
                ?>
"><?php 
                echo stripslashes($value);
                ?>
</textarea><?php 
            }
            ?>


                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'select') {
            ?>
            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row geodir_custom_fields clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <?php 
            $option_values_arr = geodir_string_values_to_options($option_values);
            $select_options = '';
            if (!empty($option_values_arr)) {
                foreach ($option_values_arr as $option_row) {
                    if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
                        $option_label = isset($option_row['label']) ? $option_row['label'] : '';
                        $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
                    } else {
                        $option_label = isset($option_row['label']) ? $option_row['label'] : '';
                        $option_value = isset($option_row['value']) ? $option_row['value'] : '';
                        $selected = $option_value == $value ? 'selected="selected"' : '';
                        $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
                    }
                }
            }
            ?>
                <select field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                        class="geodir_textfield textfield_x chosen_select"
                        data-placeholder="<?php 
            echo __('Choose', 'geodirectory') . ' ' . $site_title . '&hellip;';
            ?>
"
                        option-ajaxchosen="false"><?php 
            echo $select_options;
            ?>
</select>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } else {
            if ($type == 'multiselect') {
                $multi_display = 'select';
                if (!empty($val['extra_fields'])) {
                    $multi_display = unserialize($val['extra_fields']);
                }
                ?>
            <div id="<?php 
                echo $name;
                ?>
_row"
                 class="<?php 
                if ($is_required) {
                    echo 'required_field';
                }
                ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
                $site_title = __($site_title, 'geodirectory');
                echo trim($site_title) ? $site_title : '&nbsp;';
                ?>
                    <?php 
                if ($is_required) {
                    echo '<span>*</span>';
                }
                ?>
                </label>
                <input type="hidden" name="gd_field_<?php 
                echo $name;
                ?>
" value="1"/>
                <?php 
                if ($multi_display == 'select') {
                    ?>
                <div class="geodir_multiselect_list">
                    <select field_type="<?php 
                    echo $type;
                    ?>
" name="<?php 
                    echo $name;
                    ?>
[]" id="<?php 
                    echo $name;
                    ?>
"
                            multiple="multiple" class="geodir_textfield textfield_x chosen_select"
                            data-placeholder="<?php 
                    _e('Select', 'geodirectory');
                    ?>
"
                            option-ajaxchosen="false">
                        <?php 
                } else {
                    echo '<ul class="gd_multi_choice">';
                }
                $option_values_arr = geodir_string_values_to_options($option_values);
                $select_options = '';
                if (!empty($option_values_arr)) {
                    foreach ($option_values_arr as $option_row) {
                        if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
                            $option_label = isset($option_row['label']) ? $option_row['label'] : '';
                            if ($multi_display == 'select') {
                                $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
                            } else {
                                $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : '';
                            }
                        } else {
                            $option_label = isset($option_row['label']) ? $option_row['label'] : '';
                            $option_value = isset($option_row['value']) ? $option_row['value'] : '';
                            $selected = $option_value == $value ? 'selected="selected"' : '';
                            $selected = '';
                            $checked = '';
                            if (!is_array($value) && trim($value) != '' || is_array($value) && !empty($value)) {
                                if (!is_array($value)) {
                                    $value_array = explode(',', $value);
                                } else {
                                    $value_array = $value;
                                }
                                if (is_array($value_array)) {
                                    if (in_array($option_value, $value_array)) {
                                        $selected = 'selected="selected"';
                                        $checked = 'checked="checked"';
                                    }
                                }
                            }
                            if ($multi_display == 'select') {
                                $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
                            } else {
                                $select_options .= '<li><input name="' . $name . '[]" ' . $checked . ' value="' . esc_attr($option_value) . '" class="gd-' . $multi_display . '" field_type="' . $multi_display . '" type="' . $multi_display . '" />&nbsp;' . $option_label . ' </li>';
                            }
                        }
                    }
                }
                echo $select_options;
                if ($multi_display == 'select') {
                    ?>
</select></div>
            <?php 
                } else {
                    ?>
</ul><?php 
                }
                ?>
                <span class="geodir_message_note"><?php 
                _e($admin_desc, 'geodirectory');
                ?>
</span>
                <?php 
                if ($is_required) {
                    ?>
                    <span class="geodir_message_error"><?php 
                    _e($required_msg, 'geodirectory');
                    ?>
</span>
                <?php 
                }
                ?>
            </div>
        <?php 
            } else {
                if ($type == 'html') {
                    ?>

            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo trim($site_title) ? $site_title : '&nbsp;';
                    ?>
                    <?php 
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
                </label>

                <?php 
                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
                    ?>

                <div class="editor" field_id="<?php 
                    echo $name;
                    ?>
" field_type="editor">
                    <?php 
                    wp_editor(stripslashes($value), $name, $editor_settings);
                    ?>
                </div>

                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>

            </div>
        <?php 
                } elseif ($type == 'datepicker') {
                    if ($extra_fields['date_format'] == '') {
                        $extra_fields['date_format'] = 'yy-mm-dd';
                    }
                    $search = array('dd', 'mm', 'yy');
                    $replace = array('d', 'm', 'Y');
                    $date_format = str_replace($search, $replace, $extra_fields['date_format']);
                    if ($value && !isset($_REQUEST['backandedit'])) {
                        $time = strtotime($value);
                        $value = date($date_format, $time);
                    }
                    ?>
            <script type="text/javascript">

                jQuery(function () {

                    jQuery("#<?php 
                    echo $name;
                    ?>
").datepicker({changeMonth: true, changeYear: true,});

                    jQuery("#<?php 
                    echo $name;
                    ?>
").datepicker("option", "dateFormat", '<?php 
                    echo $extra_fields['date_format'];
                    ?>
');

                    <?php 
                    if (!empty($value)) {
                        ?>
                    jQuery("#<?php 
                        echo $name;
                        ?>
").datepicker("setDate", "<?php 
                        echo $value;
                        ?>
");
                    <?php 
                    }
                    ?>

                });

            </script>
            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">
                <label>

                    <?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo trim($site_title) ? $site_title : '&nbsp;';
                    ?>
                    <?php 
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
                </label>

                <input field_type="<?php 
                    echo $type;
                    ?>
" name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
"
                       value="<?php 
                    echo esc_attr($value);
                    ?>
" type="text" class="geodir_textfield"/>

                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>
            </div>

        <?php 
                } elseif ($type == 'time') {
                    if ($value != '') {
                        $value = date('H:i', strtotime($value));
                    }
                    ?>
            <script type="text/javascript">
                jQuery(document).ready(function () {

                    jQuery('#<?php 
                    echo $name;
                    ?>
').timepicker({
                        showPeriod: true,
                        showLeadingZero: true,
                        showPeriod: true,
                    });
                });
            </script>
            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">
                <label>

                    <?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo trim($site_title) ? $site_title : '&nbsp;';
                    ?>
                    <?php 
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
                </label>
                <input readonly="readonly" field_type="<?php 
                    echo $type;
                    ?>
" name="<?php 
                    echo $name;
                    ?>
"
                       id="<?php 
                    echo $name;
                    ?>
" value="<?php 
                    echo esc_attr($value);
                    ?>
" type="text" class="geodir_textfield"/>

                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>
            </div>

        <?php 
                } elseif ($type == 'taxonomy') {
                    if ($value == $val['default']) {
                        $value = '';
                    }
                    ?>
            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo trim($site_title) ? $site_title : '&nbsp;';
                    ?>
                    <?php 
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
                </label>

                <div id="<?php 
                    echo $name;
                    ?>
" class="geodir_taxonomy_field" style="float:left; width:70%;">
                    <?php 
                    global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats;
                    $exclude_cats = array();
                    if ($is_admin == '1') {
                        $post_type = get_post_type();
                        $package_info = array();
                        $package_info = (array) geodir_post_package_info($package_info, $post, $post_type);
                        if (!empty($package_info)) {
                            if (isset($package_info['cat']) && $package_info['cat'] != '') {
                                $exclude_cats = explode(',', $package_info['cat']);
                            }
                        }
                    }
                    $cat_display = unserialize($val['extra_fields']);
                    if (isset($_REQUEST['backandedit']) && (is_array($post_cat[$name]) && !empty($post_cat[$name]))) {
                        $post_cat = implode(",", $post_cat[$name]);
                    } else {
                        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
                            $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true);
                        }
                    }
                    global $geodir_addon_list;
                    if (!empty($geodir_addon_list) && array_key_exists('geodir_payment_manager', $geodir_addon_list) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
                        $catadd_limit = $wpdb->get_var($wpdb->prepare("SELECT cat_limit FROM " . GEODIR_PRICE_TABLE . " WHERE pid = %d", array($package_id)));
                    } else {
                        $catadd_limit = 0;
                    }
                    if ($cat_display != '' && $cat_display != 'ajax_chained') {
                        $required_limit_msg = '';
                        if ($catadd_limit > 0 && $cat_display != 'select' && $cat_display != 'radio') {
                            $required_limit_msg = __('Only select', 'geodirectory') . ' ' . $catadd_limit . __(' categories for this package.', 'geodirectory');
                        } else {
                            $required_limit_msg = $required_msg;
                        }
                        echo '<input type="hidden" cat_limit="' . $catadd_limit . '" id="cat_limit" value="' . esc_attr($required_limit_msg) . '" name="cat_limit[' . $name . ']"  />';
                        if ($cat_display == 'select' || $cat_display == 'multiselect') {
                            $cat_display == '';
                            $multiple = '';
                            if ($cat_display == 'multiselect') {
                                $multiple = 'multiple="multiple"';
                            }
                            echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">';
                            if ($cat_display == 'select') {
                                echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>';
                            }
                        }
                        echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0);
                        if ($cat_display == 'select' || $cat_display == 'multiselect') {
                            echo '</select>';
                        }
                    } else {
                        echo geodir_custom_taxonomy_walker2($name, $catadd_limit);
                    }
                    ?>
                </div>

                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>
            </div>

        <?php 
                } elseif ($type == 'file') {
                    ?>

            <?php 
                    // adjust values here
                    $file_id = $name;
                    // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
                    if ($value != '') {
                        $file_value = trim($value, ",");
                        // this will be initial value of the above form field. Image urls.
                    } else {
                        $file_value = '';
                    }
                    if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) {
                        $file_multiple = true;
                    } else {
                        $file_multiple = false;
                    }
                    if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) {
                        $file_image_limit = $extra_fields['image_limit'];
                    } else {
                        $file_image_limit = 1;
                    }
                    $file_width = geodir_media_image_large_width();
                    // If you want to automatically resize all uploaded images then provide width here (in pixels)
                    $file_height = geodir_media_image_large_height();
                    // If you want to automatically resize all uploaded images then provide height here (in pixels)
                    if (!empty($file_value)) {
                        $curImages = explode(',', $file_value);
                        if (!empty($curImages)) {
                            $file_totImg = count($curImages);
                        }
                    }
                    $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? implode(",", $extra_fields['gd_file_types']) : '';
                    $display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : '';
                    ?>
            <?php 
                    /*?> <h5 class="geodir-form_title"> <?php echo $site_title; ?>
                    			 <?php if($file_image_limit!=0 && $file_image_limit==1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('image with this package').')</small>';} ?>
                    			 <?php if($file_image_limit!=0 && $file_image_limit>1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('images with this package').')</small>';} ?>
                    			 <?php if($file_image_limit==0){echo '<br /><small>('.__('You can upload unlimited images with this package').')</small>';} ?>
                    		</h5>   <?php */
                    ?>

            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">

                <div id="<?php 
                    echo $file_id;
                    ?>
dropbox" align="center" style="">
                    <label
                        style="text-align:left; padding-top:10px;"><?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo $site_title;
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
</label>
                    <input class="geodir-custom-file-upload" field_type="file" type="hidden"
                           name="<?php 
                    echo $file_id;
                    ?>
" id="<?php 
                    echo $file_id;
                    ?>
"
                           value="<?php 
                    echo esc_attr($file_value);
                    ?>
"/>
                    <input type="hidden" name="<?php 
                    echo $file_id;
                    ?>
image_limit"
                           id="<?php 
                    echo $file_id;
                    ?>
image_limit" value="<?php 
                    echo $file_image_limit;
                    ?>
"/>
					<?php 
                    if ($allowed_file_types != '') {
                        ?>
					<input type="hidden" name="<?php 
                        echo $file_id;
                        ?>
_allowed_types"
                           id="<?php 
                        echo $file_id;
                        ?>
_allowed_types" value="<?php 
                        echo esc_attr($allowed_file_types);
                        ?>
" data-exts="<?php 
                        echo esc_attr($display_file_types);
                        ?>
"/>
					<?php 
                    }
                    ?>
                    <input type="hidden" name="<?php 
                    echo $file_id;
                    ?>
totImg" id="<?php 
                    echo $file_id;
                    ?>
totImg"
                           value="<?php 
                    if (isset($file_totImg)) {
                        echo esc_attr($file_totImg);
                    } else {
                        echo '0';
                    }
                    ?>
"/>

                    <div style="float:left; width:55%;">
                        <div
                            class="plupload-upload-uic hide-if-no-js <?php 
                    if ($file_multiple) {
                        ?>
plupload-upload-uic-multiple<?php 
                    }
                    ?>
"
                            id="<?php 
                    echo $file_id;
                    ?>
plupload-upload-ui" style="float:left; width:30%;">
                            <?php 
                    /*?><h4><?php _e('Drop files to upload');?></h4><br/><?php */
                    ?>
                            <input id="<?php 
                    echo $file_id;
                    ?>
plupload-browse-button" type="button"
                                   value="<?php 
                    $file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory');
                    ?>
"
                                   class="geodir_button" style="margin-top:10px;"/>
                            <span class="ajaxnonceplu"
                                  id="ajaxnonceplu<?php 
                    echo wp_create_nonce($file_id . 'pluploadan');
                    ?>
"></span>
                            <?php 
                    if ($file_width && $file_height) {
                        ?>
                                <span class="plupload-resize"></span>
                                <span class="plupload-width" id="plupload-width<?php 
                        echo $file_width;
                        ?>
"></span>
                                <span class="plupload-height" id="plupload-height<?php 
                        echo $file_height;
                        ?>
"></span>
                            <?php 
                    }
                    ?>
                            <div class="filelist"></div>
                        </div>
                        <div
                            class="plupload-thumbs <?php 
                    if ($file_multiple) {
                        ?>
plupload-thumbs-multiple<?php 
                    }
                    ?>
 "
                            id="<?php 
                    echo $file_id;
                    ?>
plupload-thumbs"
                            style=" clear:inherit; margin-top:0; margin-left:15px; padding-top:10px; float:left; width:50%;">
                        </div>
                        <?php 
                    /*?><span id="upload-msg" ><?php _e('Please drag &amp; drop the images to rearrange the order');?></span><?php */
                    ?>

                        <span id="<?php 
                    echo $file_id;
                    ?>
upload-error" style="display:none"></span>

                    </div>
                </div>
                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
 <?php 
                    echo $display_file_types != '' ? __('Allowed file types:', 'geodirectory') . ' ' . $display_file_types : '';
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>
            </div>


        <?php 
                }
            }
        }
        /**
         * Called after the custom fields info is output for submitting a post.
         *
         * Used dynamic hook type geodir_after_custom_form_field_$name.
         *
         * @since 1.0.0
         * @param string $listing_type The post post type.
         * @param int $package_id The price package ID for the post.
         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
         * @see 'geodir_before_custom_form_field_$name'
         */
        do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
    }
}
/**
 * Get the custom fields texts for translation
 *
 * @since 1.4.2
 * @since 1.5.7 Option values are translatable via db translation.
 * @package GeoDirectory
 *
 * @global object $wpdb WordPress database abstraction object.
 *
 * @param  array $translation_texts Array of text strings.
 * @return array Translation texts.
 */
function geodir_load_custom_field_translation($translation_texts = array())
{
    global $wpdb;
    // Custom fields table
    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
    $rows = $wpdb->get_results($sql);
    if (!empty($rows)) {
        foreach ($rows as $row) {
            if (!empty($row->admin_title)) {
                $translation_texts[] = stripslashes_deep($row->admin_title);
            }
            if (!empty($row->admin_desc)) {
                $translation_texts[] = stripslashes_deep($row->admin_desc);
            }
            if (!empty($row->site_title)) {
                $translation_texts[] = stripslashes_deep($row->site_title);
            }
            if (!empty($row->clabels)) {
                $translation_texts[] = stripslashes_deep($row->clabels);
            }
            if (!empty($row->required_msg)) {
                $translation_texts[] = stripslashes_deep($row->required_msg);
            }
            if (!empty($row->default_value)) {
                $translation_texts[] = stripslashes_deep($row->default_value);
            }
            if (!empty($row->option_values)) {
                $option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
                if (!empty($option_values)) {
                    foreach ($option_values as $option_value) {
                        if (!empty($option_value['label'])) {
                            $translation_texts[] = $option_value['label'];
                        }
                    }
                }
            }
        }
    }
    // Custom sorting fields table
    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
    $rows = $wpdb->get_results($sql);
    if (!empty($rows)) {
        foreach ($rows as $row) {
            if (!empty($row->site_title)) {
                $translation_texts[] = stripslashes_deep($row->site_title);
            }
            if (!empty($row->asc_title)) {
                $translation_texts[] = stripslashes_deep($row->asc_title);
            }
            if (!empty($row->desc_title)) {
                $translation_texts[] = stripslashes_deep($row->desc_title);
            }
        }
    }
    // Advance search filter fields table
    if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
        $sql = "SELECT field_site_name, front_search_title, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE;
        $rows = $wpdb->get_results($sql);
        if (!empty($rows)) {
            foreach ($rows as $row) {
                if (!empty($row->field_site_name)) {
                    $translation_texts[] = stripslashes_deep($row->field_site_name);
                }
                if (!empty($row->front_search_title)) {
                    $translation_texts[] = stripslashes_deep($row->front_search_title);
                }
                if (!empty($row->field_desc)) {
                    $translation_texts[] = stripslashes_deep($row->field_desc);
                }
            }
        }
    }
    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
    return $translation_texts;
}
function geodir_advance_search_listing_page_title($list_title)
{
    if (!geodir_is_page('search')) {
        return $list_title;
    }
    $gd_post_type = geodir_get_current_posttype();
    $post_type_info = get_post_type_object($gd_post_type);
    if (trim(get_search_query()) == '') {
        $list_title = __('Search', GEODIRECTORY_TEXTDOMAIN) . ' ' . __(ucfirst($post_type_info->labels->name), GEODIRECTORY_TEXTDOMAIN) . __(' :', GEODIRECTORY_TEXTDOMAIN);
    }
    if (!get_option('geodir_search_display_searched_params')) {
        return $list_title;
    }
    $custom_fields = geodir_advance_search_get_advance_search_fields($gd_post_type);
    $search_title = array();
    if (isset($_REQUEST['snear']) && $_REQUEST['snear'] != '') {
        $search_title[] = '<label class="gd-adv-search-label gd-adv-search-near">' . $_REQUEST['snear'] . '</label>';
    }
    if (!empty($custom_fields)) {
        foreach ($custom_fields as $custom_field) {
            $site_htmlvar_name = $custom_field->site_htmlvar_name;
            $field_site_name = $custom_field->field_site_name;
            $field_site_type = $custom_field->field_site_type;
            $front_search_title = $custom_field->front_search_title != '' ? $custom_field->front_search_title : $field_site_name;
            $field_input_type = $custom_field->field_input_type;
            $search_condition = $custom_field->search_condition;
            $field_data_type = $custom_field->field_data_type;
            switch ($field_input_type) {
                case 'RANGE':
                    switch ($search_condition) {
                        case 'SINGLE':
                            if (isset($_REQUEST['s' . $site_htmlvar_name]) && $_REQUEST['s' . $site_htmlvar_name] != '') {
                                $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"';
                                $search_title[] = '<label class="gd-adv-search-label gd-adv-search-range gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $_REQUEST['s' . $site_htmlvar_name] . '</label>';
                            }
                            break;
                        case 'FROM':
                            $minvalue = isset($_REQUEST['smin' . $site_htmlvar_name]) && !empty($_REQUEST['smin' . $site_htmlvar_name]) ? $_REQUEST['smin' . $site_htmlvar_name] : '';
                            $maxvalue = isset($_REQUEST['smax' . $site_htmlvar_name]) && !empty($_REQUEST['smax' . $site_htmlvar_name]) ? $_REQUEST['smax' . $site_htmlvar_name] : '';
                            $this_search = '';
                            if ($minvalue != '' && $maxvalue != '') {
                                $this_search = $minvalue . ' - ' . $maxvalue;
                            } else {
                                if ($minvalue != '' && $maxvalue == '') {
                                    $this_search = __('From:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $minvalue;
                                } else {
                                    if ($minvalue == '' && $maxvalue != '') {
                                        $this_search = __('To:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $maxvalue;
                                    }
                                }
                            }
                            if ($this_search != '') {
                                $extra_attrs = 'data-name="smin' . $site_htmlvar_name . '" data-names="smax' . $site_htmlvar_name . '"';
                                $search_title[] = '<label class="gd-adv-search-label gd-adv-search-range gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $this_search . '</label>';
                            }
                            break;
                        case 'RADIO':
                            if (isset($_REQUEST['s' . $site_htmlvar_name]) && $_REQUEST['s' . $site_htmlvar_name] != '') {
                                $uom = get_option('geodir_search_dist_1');
                                $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"';
                                $search_title[] = '<label class="gd-adv-search-label gd-adv-search-range gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . __('Within', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . (int) $_REQUEST['s' . $site_htmlvar_name] . ' ' . __($uom, GEODIRECTORY_TEXTDOMAIN) . '</label>';
                            }
                            break;
                        default:
                            if (isset($_REQUEST['s' . $site_htmlvar_name]) && $_REQUEST['s' . $site_htmlvar_name] != '') {
                                $serchlist = explode("-", $_REQUEST['s' . $site_htmlvar_name]);
                                if (!empty($serchlist)) {
                                    $first_value = $serchlist[0];
                                    $second_value = isset($serchlist[1]) ? trim($serchlist[1], ' ') : '';
                                    $rest = substr($second_value, 0, 4);
                                    $this_search = '';
                                    if ($rest == 'Less') {
                                        $this_search = __('To:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $first_value;
                                    } else {
                                        if ($rest == 'More') {
                                            $this_search = __('From:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $first_value;
                                        } else {
                                            if ($second_value != '') {
                                                $this_search = $first_value . ' - ' . $second_value;
                                            }
                                        }
                                    }
                                    if ($this_search != '') {
                                        $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"';
                                        $search_title[] = '<label class="gd-adv-search-label gd-adv-search-range gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $this_search . '</label>';
                                    }
                                }
                            }
                            break;
                    }
                    break;
                case 'DATE':
                    $search_date = '';
                    $single = '';
                    $this_search = '';
                    $value = isset($_REQUEST['s' . $site_htmlvar_name]) && !empty($_REQUEST['s' . $site_htmlvar_name]) ? $_REQUEST['s' . $site_htmlvar_name] : '';
                    $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"';
                    if ($value) {
                        $minvalue = $value;
                        $maxvalue = '';
                        $single = '1';
                    } else {
                        $minvalue = isset($_REQUEST['smin' . $site_htmlvar_name]) && !empty($_REQUEST['smin' . $site_htmlvar_name]) ? $_REQUEST['smin' . $site_htmlvar_name] : '';
                        $maxvalue = isset($_REQUEST['smax' . $site_htmlvar_name]) && !empty($_REQUEST['smax' . $site_htmlvar_name]) ? $_REQUEST['smax' . $site_htmlvar_name] : '';
                        $extra_attrs = 'data-name="smin' . $site_htmlvar_name . '" data-names="smax' . $site_htmlvar_name . '"';
                    }
                    if ($site_htmlvar_name == 'event') {
                        $event_start = isset($_REQUEST['event_start']) && !empty($_REQUEST['event_start']) ? $_REQUEST['event_start'] : '';
                        $event_end = isset($_REQUEST['event_end']) && !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
                        $extra_attrs = 'data-name="event_start" data-names="event_end"';
                        if ($event_start != '' && $event_end == '') {
                            $this_search = __('From:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $event_start;
                        } else {
                            if ($event_start == '' && $event_end != '') {
                                $this_search = __('To:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $event_end;
                            } else {
                                if ($event_start != '' && $event_end != '') {
                                    $this_search = $event_start . ' - ' . $event_end;
                                }
                            }
                        }
                        if ($this_search != '') {
                            $search_title[] = '<label class="gd-adv-search-label gd-adv-search-date gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $this_search . '</label>';
                        }
                    } else {
                        if ($field_data_type == 'DATE' || $field_data_type == 'TIME') {
                            $start_date = date('Y-m-d', strtotime($minvalue));
                            $start_end = date('Y-m-d', strtotime($maxvalue));
                            if ($single == '1') {
                                $search_title[] = '<label class="gd-adv-search-label gd-adv-search-date gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $minvalue . '</label>';
                            } else {
                                $this_search = '';
                                if ($minvalue != '' && $maxvalue == '') {
                                    $this_search = __('From:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $minvalue;
                                } else {
                                    if ($minvalue == '' && $maxvalue != '') {
                                        $this_search = __('To:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $maxvalue;
                                    } else {
                                        if ($minvalue != '' && $maxvalue != '') {
                                            $this_search = $minvalue . ' - ' . $maxvalue;
                                        }
                                    }
                                }
                                if ($this_search != '') {
                                    $search_title[] = '<label class="gd-adv-search-label gd-adv-search-date gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $this_search . '</label>';
                                }
                            }
                        }
                    }
                    break;
                default:
                    if (isset($_REQUEST['s' . $site_htmlvar_name]) && (is_array($_REQUEST['s' . $site_htmlvar_name]) && !empty($_REQUEST['s' . $site_htmlvar_name]) || !is_array($_REQUEST['s' . $site_htmlvar_name]) && $_REQUEST['s' . $site_htmlvar_name] != '')) {
                        $value = $_REQUEST['s' . $site_htmlvar_name];
                        if (is_array($_REQUEST['s' . $site_htmlvar_name])) {
                            $extra_attrs = 'data-name="s' . $site_htmlvar_name . '[]"';
                            $values = $_REQUEST['s' . $site_htmlvar_name];
                            $value = '';
                            if ($site_htmlvar_name == $gd_post_type . 'category') {
                                $value = array();
                                foreach ($values as $value_id) {
                                    $value_term = get_term($value_id, $site_htmlvar_name);
                                    if (!empty($value_term) && isset($value_term->name)) {
                                        $value[] = $value_term->name;
                                    }
                                }
                                $value = !empty($value) ? implode(', ', $value) : '';
                            } else {
                                $field_option_values = geodir_advance_search_field_option_values($gd_post_type, $site_htmlvar_name);
                                $field_option_values = geodir_string_values_to_options($field_option_values);
                                if (!empty($field_option_values)) {
                                    $value = array();
                                    foreach ($field_option_values as $option_value) {
                                        $option_label = isset($option_value['label']) ? $option_value['label'] : '';
                                        $option_val = isset($option_value['value']) ? $option_value['value'] : $option_label;
                                        if ($option_label != '' && $option_val != '' && in_array($option_val, $_REQUEST['s' . $site_htmlvar_name])) {
                                            $value[] = __(ucfirst($option_label), GEODIRECTORY_TEXTDOMAIN);
                                        }
                                    }
                                    $value = !empty($value) ? implode(', ', $value) : '';
                                } else {
                                    $value = implode(', ', $values);
                                }
                            }
                        } else {
                            $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"';
                            if ($site_htmlvar_name == $gd_post_type . 'category') {
                                $value = '';
                                $value_term = get_term($_REQUEST['s' . $site_htmlvar_name], $site_htmlvar_name);
                                if (!empty($value_term) && isset($value_term->name)) {
                                    $value = $value_term->name;
                                }
                            } else {
                                $field_option_values = geodir_advance_search_field_option_values($gd_post_type, $site_htmlvar_name);
                                $field_option_values = geodir_string_values_to_options($field_option_values);
                                if (!empty($field_option_values)) {
                                    $value = array();
                                    foreach ($field_option_values as $option_value) {
                                        $option_label = isset($option_value['label']) ? $option_value['label'] : '';
                                        $option_val = isset($option_value['value']) ? $option_value['value'] : $option_label;
                                        if ($option_label != '' && $option_val != '' && $option_val == $_REQUEST['s' . $site_htmlvar_name]) {
                                            $value[] = __(ucfirst($option_label), GEODIRECTORY_TEXTDOMAIN);
                                        }
                                    }
                                    $value = !empty($value) ? implode(', ', $value) : '';
                                }
                                if ($field_site_type == 'checkbox' && (int) $_REQUEST['s' . $site_htmlvar_name] == 1) {
                                    $value = __($front_search_title, GEODIRADVANCESEARCH_TEXTDOMAIN);
                                }
                            }
                        }
                        if ($value != '') {
                            $search_title[] = '<label class="gd-adv-search-label gd-adv-search-default gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $value . '</label>';
                        }
                    }
                    break;
            }
        }
    }
    if (!empty($search_title)) {
        $search_title = '<div class="gd-adv-search-labels">' . implode($search_title, '') . '</div>';
        $search_title = apply_filters('geodir_advance_search_filter_title', $search_title);
        $list_title .= $search_title;
    }
    return $list_title;
}
 /**
  * Show listing info depending on field location.
  *
  * @since 1.0.0
  * @since 1.5.7 Custom fields option values added to db translation.
  *              Changes to display url fields title.
  * @package GeoDirectory
  * @global object $wpdb WordPress Database object.
  * @global object $post The current post object.
  * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc.
  * @return string Returns listing info html.
  */
 function geodir_show_listing_info($fields_location = '')
 {
     global $post, $preview, $wpdb;
     $payment_info = array();
     $package_info = array();
     $package_info = geodir_post_package_info($package_info, $post);
     //return;
     $post_package_id = $package_info->pid;
     $p_type = geodir_get_current_posttype() ? geodir_get_current_posttype() : $post->post_type;
     ob_start();
     $fields_info = geodir_post_custom_fields($post_package_id, 'default', $p_type, $fields_location);
     if (!empty($fields_info)) {
         //echo '<div class="geodir-company_info field-group">';
         $field_set_start = 0;
         if ($fields_location == 'detail') {
             $i = 1;
         }
         foreach ($fields_info as $type) {
             $type = stripslashes_deep($type);
             // strip slashes
             $html = '';
             $html_var = '';
             $field_icon = '';
             $variables_array = array();
             if ($fields_location == 'detail' && isset($type['show_as_tab']) && (int) $type['show_as_tab'] == 1 && in_array($type['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
                 continue;
             }
             if ($type['type'] != 'fieldset') {
                 $variables_array['post_id'] = $post->ID;
                 $variables_array['label'] = __($type['site_title'], 'geodirectory');
                 $variables_array['value'] = '';
                 if (isset($post->{$type['htmlvar_name']})) {
                     $variables_array['value'] = $post->{$type['htmlvar_name']};
                 }
             }
             //if($type['field_icon'])
             if (strpos($type['field_icon'], 'http') !== false) {
                 $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
             } elseif (strpos($type['field_icon'], 'fa fa-') !== false) {
                 $field_icon = '<i class="' . $type['field_icon'] . '"></i>';
             }
             //else{$field_icon = $type['field_icon'];}
             switch ($type['type']) {
                 case 'fieldset':
                     $fieldset_class = 'fieldset-' . sanitize_title_with_dashes($type['site_title']);
                     if ($field_set_start == 1) {
                         echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2 class="' . $fieldset_class . '">' . __($type['site_title'], 'geodirectory') . '</h2>';
                     } else {
                         echo '<h2 class="' . $fieldset_class . '">' . __($type['site_title'], 'geodirectory') . '</h2>';
                         $field_set_start = 1;
                     }
                     break;
                 case 'address':
                     $html_var = $type['htmlvar_name'] . '_address';
                     if ($type['extra_fields']) {
                         $extra_fields = unserialize($type['extra_fields']);
                         $addition_fields = '';
                         if (!empty($extra_fields)) {
                             /**
                              * Filter "show city in address" value.
                              *
                              * @since 1.0.0
                              */
                             $show_city_in_address = apply_filters('geodir_show_city_in_address', false);
                             if (isset($extra_fields['show_city']) && $extra_fields['show_city'] && $show_city_in_address) {
                                 $field = $type['htmlvar_name'] . '_city';
                                 if ($post->{$field}) {
                                     $addition_fields .= ', ' . $post->{$field};
                                 }
                             }
                             if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
                                 $field = $type['htmlvar_name'] . '_zip';
                                 if ($post->{$field}) {
                                     $addition_fields .= ', ' . $post->{$field};
                                 }
                             }
                         }
                     }
                     /*if($type['extra_fields'])
                     		{
                     			
                     			$extra_fields = unserialize($type['extra_fields']);
                     			
                     			$addition_fields = '';
                     			
                     			if(!empty($extra_fields))
                     			{
                     				if($extra_fields['show_city'])
                     				{
                     					$field = $type['htmlvar_name'].'_city';
                     					if($post->$field)
                     					{
                     						$addition_fields .= ', '.$post->$field;
                     					}
                     				}
                     				
                     				if($extra_fields['show_region'])
                     				{
                     					$field = $type['htmlvar_name'].'_region';
                     					if($post->$field)
                     					{
                     						$addition_fields .= ', '.$post->$field;
                     					}
                     				}
                     				
                     				if($extra_fields['show_country'])
                     				{
                     					$field = $type['htmlvar_name'].'_country';
                     					if($post->$field)
                     					{
                     						$addition_fields .= ', '.$post->$field;
                     					}
                     				}
                     				
                     				if($extra_fields['show_zip'])
                     				{
                     					$field = $type['htmlvar_name'].'_zip';
                     					if($post->$field)
                     					{
                     						$addition_fields .= ', '.$post->$field;
                     					}
                     				}
                     				
                     			}
                     		
                     		}*/
                     if ($post->{$html_var}) {
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '<i class="fa fa-home"></i>';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"  itemscope itemtype="http://schema.org/PostalAddress">';
                         $html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
                         $html .= '</span>';
                         //print_r($_POST);
                         if ($preview) {
                             $html .= stripslashes($post->{$html_var}) . $addition_fields . '</p></div>';
                         } else {
                             if ($post->post_address) {
                                 $html .= '<span itemprop="streetAddress">' . $post->post_address . '</span><br>';
                             }
                             if ($post->post_city) {
                                 $html .= '<span itemprop="addressLocality">' . $post->post_city . '</span><br>';
                             }
                             if ($post->post_region) {
                                 $html .= '<span itemprop="addressRegion">' . $post->post_region . '</span><br>';
                             }
                             if ($post->post_zip) {
                                 $html .= '<span itemprop="postalCode">' . $post->post_zip . '</span><br>';
                             }
                             if ($post->post_country) {
                                 $html .= '<span itemprop="addressCountry">' . __($post->post_country, 'geodirectory') . '</span><br>';
                             }
                             $html .= '</div>';
                         }
                     }
                     $variables_array['value'] = $post->{$html_var};
                     break;
                 case 'url':
                     $html_var = $type['htmlvar_name'];
                     if ($post->{$type['htmlvar_name']}) {
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             if ($type['name'] == 'geodir_facebook') {
                                 $field_icon_af = '<i class="fa fa-facebook-square"></i>';
                             } elseif ($type['name'] == 'geodir_twitter') {
                                 $field_icon_af = '<i class="fa fa-twitter-square"></i>';
                             } else {
                                 $field_icon_af = '<i class="fa fa-link"></i>';
                             }
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $a_url = geodir_parse_custom_field_url($post->{$type['htmlvar_name']});
                         $website = !empty($a_url['url']) ? $a_url['url'] : '';
                         $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title'];
                         if (!empty($type['default_value'])) {
                             $title = $type['default_value'];
                         }
                         $title = $title != '' ? __(stripslashes($title), 'geodirectory') : '';
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         // all search engines that use the nofollow value exclude links that use it from their ranking calculation
                         $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"';
                         /**
                          * Filter custom field website name.
                          *
                          * @since 1.0.0
                          *
                          * @param string $title Website Title.
                          * @param string $website Website URL.
                          * @param int $post->ID Post ID.
                          */
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . '<a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>';
                     }
                     break;
                 case 'phone':
                     $html_var = $type['htmlvar_name'];
                     if ($post->{$type['htmlvar_name']}) {
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '<i class="fa fa-phone"></i>';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af . ($html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;');
                         $html .= '</span><a href="tel:' . preg_replace('/[^0-9+]/', '', $post->{$type['htmlvar_name']}) . '">' . stripslashes($post->{$type['htmlvar_name']}) . '</a></div>';
                     }
                     break;
                 case 'time':
                     $html_var = $type['htmlvar_name'];
                     if ($post->{$type['htmlvar_name']}) {
                         $value = '';
                         if ($post->{$type['htmlvar_name']} != '') {
                             //$value = date('h:i',strtotime($post->{$type['htmlvar_name']}));
                             $value = date(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
                         }
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '<i class="fa fa-clock-o"></i>';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
                         $html .= '</span>' . stripslashes($value) . '</div>';
                     }
                     break;
                 case 'datepicker':
                     if ($post->{$type['htmlvar_name']}) {
                         $date_format = geodir_default_date_format();
                         if ($type['extra_fields'] != '') {
                             $date_format = unserialize($type['extra_fields']);
                             $date_format = $date_format['date_format'];
                         }
                         $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy');
                         //jQuery UI datepicker format
                         $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y');
                         //PHP date format
                         $date_format = str_replace($search, $replace, $date_format);
                         $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type['htmlvar_name']}) : $post->{$type['htmlvar_name']};
                         // PHP doesn't work well with dd/mm/yyyy format
                         $value = '';
                         if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']} != "0000-00-00") {
                             $value = date($date_format, strtotime($post_htmlvar_value));
                         } else {
                             continue;
                         }
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '<i class="fa fa-calendar"></i>';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                         $html .= '</span>' . $value . '</div>';
                     }
                     break;
                 case 'text':
                     $html_var = $type['htmlvar_name'];
                     if (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']} != '' && $type['htmlvar_name'] == 'geodir_timing') {
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '<i class="fa fa-clock-o"></i>';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '&nbsp;';
                         $html .= '</span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
                     } elseif (isset($post->{$type['htmlvar_name']}) && $post->{$type['htmlvar_name']}) {
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                         $html .= '</span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
                     }
                     break;
                 case 'radio':
                     $html_var = $type['htmlvar_name'];
                     $html_val = __($post->{$type['htmlvar_name']}, 'geodirectory');
                     if ($post->{$type['htmlvar_name']} != '') {
                         if ($post->{$type['htmlvar_name']} == 'f' || $post->{$type['htmlvar_name']} == '0') {
                             $html_val = __('No', 'geodirectory');
                         } else {
                             if ($post->{$type['htmlvar_name']} == 't' || $post->{$type['htmlvar_name']} == '1') {
                                 $html_val = __('Yes', 'geodirectory');
                             } else {
                                 if (!empty($type['option_values'])) {
                                     $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true);
                                     if (!empty($cf_option_values)) {
                                         foreach ($cf_option_values as $cf_option_value) {
                                             if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
                                                 $html_val = $cf_option_value['label'];
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                         $html .= '</span>' . $html_val . '</div>';
                     }
                     break;
                 case 'checkbox':
                     $html_var = $type['htmlvar_name'];
                     if ((int) $post->{$html_var} == 1) {
                         if ($post->{$type['htmlvar_name']} == '1') {
                             $html_val = __('Yes', 'geodirectory');
                         } else {
                             $html_val = __('No', 'geodirectory');
                         }
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                         $html .= '</span>' . $html_val . '</div>';
                     }
                     break;
                 case 'select':
                     $html_var = $type['htmlvar_name'];
                     if ($post->{$type['htmlvar_name']}) {
                         $field_value = __($post->{$type}['htmlvar_name'], 'geodirectory');
                         if (!empty($type['option_values'])) {
                             $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true);
                             if (!empty($cf_option_values)) {
                                 foreach ($cf_option_values as $cf_option_value) {
                                     if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type}['htmlvar_name']) {
                                         $field_value = $cf_option_value['label'];
                                     }
                                 }
                             }
                         }
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                         $html .= '</span>' . $field_value . '</div>';
                     }
                     break;
                 case 'multiselect':
                     $html_var = $type['htmlvar_name'];
                     if (!empty($post->{$type['htmlvar_name']})) {
                         if (is_array($post->{$type['htmlvar_name']})) {
                             $post->{$type['htmlvar_name']} = implode(', ', $post->{$type['htmlvar_name']});
                         }
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $field_values = explode(',', trim($post->{$type}['htmlvar_name'], ","));
                         $option_values = array();
                         if (!empty($type['option_values'])) {
                             $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true);
                             if (!empty($cf_option_values)) {
                                 foreach ($cf_option_values as $cf_option_value) {
                                     if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
                                         $option_values[] = $cf_option_value['label'];
                                     }
                                 }
                             }
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                         $html .= '</span>';
                         if (count($option_values) > 1) {
                             $html .= '<ul>';
                             foreach ($option_values as $val) {
                                 $html .= '<li>' . $val . '</li>';
                             }
                             $html .= '</ul>';
                         } else {
                             $html .= $post->{$type}['htmlvar_name'];
                         }
                         $html .= '</div>';
                     }
                     break;
                 case 'email':
                     if ($type['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) {
                         continue;
                         // Remove Send Enquiry | Send To Friend from listings page
                     }
                     if ($type['htmlvar_name'] == 'geodir_email' && (isset($package_info->sendtofriend) && $package_info->sendtofriend || $post->{$type['htmlvar_name']})) {
                         $b_send_inquiry = '';
                         $b_sendtofriend = '';
                         $html = '';
                         if (!$preview) {
                             $b_send_inquiry = 'b_send_inquiry';
                             $b_sendtofriend = 'b_sendtofriend';
                             $html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>';
                         }
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '<i class="fa fa-envelope"></i>';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html .= '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
                         $seperator = '';
                         if ($post->{$type['htmlvar_name']}) {
                             $html .= '<a href="javascript:void(0);" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>';
                             $seperator = ' | ';
                         }
                         if (isset($package_info->sendtofriend) && $package_info->sendtofriend) {
                             $html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>';
                         }
                         $html .= '</span></div>';
                         if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') {
                             $html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>';
                         } elseif (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') {
                             $html .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>';
                         } elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') {
                             $html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>';
                         }
                         /*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/
                     } else {
                         if ($post->{$type['htmlvar_name']}) {
                             if (strpos($field_icon, 'http') !== false) {
                                 $field_icon_af = '';
                             } elseif ($field_icon == '') {
                                 $field_icon_af = '<i class="fa fa-envelope"></i>';
                             } else {
                                 $field_icon_af = $field_icon;
                                 $field_icon = '';
                             }
                             $geodir_odd_even = '';
                             if ($fields_location == 'detail') {
                                 $geodir_odd_even = 'geodir_more_info_odd';
                                 if ($i % 2 == 0) {
                                     $geodir_odd_even = 'geodir_more_info_even';
                                 }
                                 $i++;
                             }
                             $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
                             $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                             $html .= '</span><span class="geodir-email-address-output">';
                             $email = stripslashes($post->{$type['htmlvar_name']});
                             if ($e_split = explode('@', $email)) {
                                 /**
                                  * Filter email custom field name output.
                                  *
                                  * @since 1.5.3
                                  *
                                  * @param string $email The email string being output.
                                  * @param array $type Custom field variables array.
                                  */
                                 $email_name = apply_filters('geodir_email_field_name_output', $email, $type);
                                 $html .= "<script>document.write('<a href=\"mailto:'+'{$e_split['0']}' + '@' + '{$e_split['1']}'+'\">{$email_name}</a>')</script>";
                             } else {
                                 $html .= $email;
                             }
                             $html .= '</span></div>';
                         }
                     }
                     break;
                 case 'file':
                     $html_var = $type['htmlvar_name'];
                     if (!empty($post->{$type['htmlvar_name']})) {
                         $files = explode(",", $post->{$type['htmlvar_name']});
                         if (!empty($files)) {
                             $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL;
                             $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : '';
                             $file_paths = '';
                             foreach ($files as $file) {
                                 if (!empty($file)) {
                                     // $filetype = wp_check_filetype($file);
                                     $image_name_arr = explode('/', $file);
                                     $curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
                                     $filename = end($image_name_arr);
                                     $img_name_arr = explode('.', $filename);
                                     $arr_file_type = wp_check_filetype($filename);
                                     if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
                                         continue;
                                     }
                                     $uploaded_file_type = $arr_file_type['type'];
                                     $uploaded_file_ext = $arr_file_type['ext'];
                                     if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
                                         continue;
                                         // Invalid file type.
                                     }
                                     //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
                                     $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
                                     // If the uploaded file is image
                                     if (in_array($uploaded_file_type, $image_file_types)) {
                                         $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">';
                                         $file_paths .= '<a href="' . $file . '">';
                                         $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
                                         $file_paths .= '</a>';
                                         //$file_paths .= '<img src="'.$file.'"  />';
                                         $file_paths .= '</div>';
                                     } else {
                                         $ext_path = '_' . $html_var . '_';
                                         $filename = explode($ext_path, $filename);
                                         $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>';
                                     }
                                 }
                             }
                             if (strpos($field_icon, 'http') !== false) {
                                 $field_icon_af = '';
                             } elseif ($field_icon == '') {
                                 $field_icon_af = '';
                             } else {
                                 $field_icon_af = $field_icon;
                                 $field_icon = '';
                             }
                             $geodir_odd_even = '';
                             if ($fields_location == 'detail') {
                                 $geodir_odd_even = 'geodir_more_info_odd';
                                 if ($i % 2 == 0) {
                                     $geodir_odd_even = 'geodir_more_info_even';
                                 }
                                 $i++;
                             }
                             $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' geodir-custom-file-box ' . $type['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                             $html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">';
                             $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                             $html .= '</span>';
                             $html .= $file_paths . '</div></div>';
                         }
                     }
                     break;
                 case 'textarea':
                     $html_var = $type['htmlvar_name'];
                     if (!empty($post->{$type['htmlvar_name']})) {
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                         $html .= '</span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
                     }
                     break;
                 case 'html':
                     if (!empty($post->{$type['htmlvar_name']})) {
                         if (strpos($field_icon, 'http') !== false) {
                             $field_icon_af = '';
                         } elseif ($field_icon == '') {
                             $field_icon_af = '';
                         } else {
                             $field_icon_af = $field_icon;
                             $field_icon = '';
                         }
                         $geodir_odd_even = '';
                         if ($fields_location == 'detail') {
                             $geodir_odd_even = 'geodir_more_info_odd';
                             if ($i % 2 == 0) {
                                 $geodir_odd_even = 'geodir_more_info_even';
                             }
                             $i++;
                         }
                         $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
                         $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                         $html .= '</span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
                     }
                     break;
                 case 'taxonomy':
                     $html_var = $type['htmlvar_name'];
                     if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) {
                         $post_taxonomy = $post->post_type . 'category';
                         $field_value = $post->{$html_var};
                         $links = array();
                         $terms = array();
                         $termsOrdered = array();
                         if (!is_array($field_value)) {
                             $field_value = explode(",", trim($field_value, ","));
                         }
                         $field_value = array_unique($field_value);
                         if (!empty($field_value)) {
                             foreach ($field_value as $term) {
                                 $term = trim($term);
                                 if ($term != '') {
                                     $term = get_term_by('id', $term, $html_var);
                                     if (is_object($term)) {
                                         $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>";
                                         $terms[] = $term;
                                     }
                                 }
                             }
                             if (!empty($links)) {
                                 // order alphabetically
                                 asort($links);
                                 foreach (array_keys($links) as $key) {
                                     $termsOrdered[$key] = $terms[$key];
                                 }
                                 $terms = $termsOrdered;
                             }
                         }
                         $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object) $terms) : '';
                         if ($html_value != '') {
                             if (strpos($field_icon, 'http') !== false) {
                                 $field_icon_af = '';
                             } else {
                                 if ($field_icon == '') {
                                     $field_icon_af = '';
                                 } else {
                                     $field_icon_af = $field_icon;
                                     $field_icon = '';
                                 }
                             }
                             $geodir_odd_even = '';
                             if ($fields_location == 'detail') {
                                 $geodir_odd_even = 'geodir_more_info_odd';
                                 if ($i % 2 == 0) {
                                     $geodir_odd_even = 'geodir_more_info_even';
                                 }
                                 $i++;
                             }
                             $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af;
                             $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : '';
                             $html .= '</span> ' . $html_value . '</div>';
                         }
                     }
                     break;
             }
             if ($html) {
                 /**
                  * Called before a custom fields is output on the frontend.
                  *
                  * @since 1.0.0
                  * @param string $html_var The HTML variable name for the field.
                  */
                 do_action("geodir_before_show_{$html_var}");
                 /**
                  * Filter custom field output.
                  *
                  * @since 1.0.0
                  *
                  * @param string $html_var The HTML variable name for the field.
                  * @param string $html Custom field unfiltered HTML.
                  * @param array $variables_array Custom field variables array.
                  */
                 if ($html) {
                     echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
                 }
                 /**
                  * Called after a custom fields is output on the frontend.
                  *
                  * @since 1.0.0
                  * @param string $html_var The HTML variable name for the field.
                  */
                 do_action("geodir_after_show_{$html_var}");
             }
         }
         //echo '</div>';
     }
     return $html = ob_get_clean();
 }