Function Reference: geodir_show_filters_fields
Summary
This function has not been documented yet.
Source File
geodir_show_filters_fields() is located in geodir_advance_search_filters/geodirectory_advance_search_function.php [Line: 795]
Source Code
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 = '' ; ?> 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 ''; ?> front_search_title){echo $taxonomy_obj->front_search_title;}else{echo $taxonomy_obj->field_site_name;} ?> field_input_type=='SELECT'){ $geodir_search_field_begin = ''; } ######### 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': ?> 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 .= ''; } 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 .= ''; } } if($sort_options != ''){ echo ''; } endforeach; endif; echo $html = ob_get_clean(); }'; } } } echo "
"; $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(esc_attr($_REQUEST['s'.$taxonomy_obj->site_htmlvar_name])) : ''; } switch($taxonomy_obj->field_input_type) { case 'CHECK' : if ( $custom_term && $optgroup != '' ) { if ( $optgroup == 'start' ) { echo '
- ' . $term->name .'
'; } } else { if($geodir_search_field_selected) $geodir_search_field_selected_str = ' checked="checked" '; echo '- ' . $term->name .'
'; $increment++; } break ; case 'RADIO' : if ( $custom_term && $optgroup != '' ) { if ( $optgroup == 'start' ) { echo '- ' . $term->name .'
'; } } else { if($geodir_search_field_selected) $geodir_search_field_selected_str = ' checked="checked" '; echo '- ' . $term->name .'
'; $increment++; } break ; case 'SELECT' : if ( $custom_term && $optgroup != '' ) { if ( $optgroup == 'start' ) { echo ''; } } else { if($geodir_search_field_selected) $geodir_search_field_selected_str = ' selected="selected" '; echo ''; $increment++; } break ; case 'LINK' : if ( $custom_term && $optgroup != '' ) { if ( $optgroup == 'start' ) { echo '- '. $term->name . '
'; } } else { echo '- '.$term->name .'
'; $increment++; } break; case 'RANGE': ############# RANGE VARIABLES ########## { $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(esc_attr($_REQUEST['s'.$taxonomy_obj->site_htmlvar_name])) : ''; ?> site_htmlvar_name]); $smaxcustom_value = @esc_attr($_REQUEST['smax'.$taxonomy_obj->site_htmlvar_name]); ?>' name='sminsite_htmlvar_name;?>' value=''> ' name='smaxsite_htmlvar_name;?>' value=''>site_htmlvar_name]); $increment =1; while($i<=$search_maximum_value){ if($k==0) { $value = $search_starting_value.'-Less'; ?>- searching_range_mode==1){ $display_value=$j; $value = $j.'-Less'; }else{ $display_value=''; } ?>
- searching_range_mode==1){ $display_value=$j; $value = $j.'-Less'; }else{ $display_value=''; } ?>
- $search_maximum_value) { if($j!=$search_maximum_value){ $value = $j.'-'.$search_maximum_value; ?>
- searching_range_mode==1 && $j==$search_maximum_value){ $display_value=$j; $value = $j.'-Less'; ?>
- site_htmlvar_name]); ?> $moreoption && !empty($moreoption)) $classname = 'class="more"'; echo '
- ' . __('Within',GEODIRADVANCESEARCH_TEXTDOMAIN).' '.$i.' '.__($uom, GEODIRECTORY_TEXTDOMAIN). '
'; $increment++; endfor; //echo ""; 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(esc_attr($_REQUEST['s'.$taxonomy_obj->site_htmlvar_name])) : ''; ?> search_condition=='FROM' && $taxonomy_obj->site_htmlvar_name!='event'){ $smincustom_value = @esc_attr($_REQUEST['smin'.$taxonomy_obj->site_htmlvar_name]); $smaxcustom_value = @esc_attr($_REQUEST['smax'.$taxonomy_obj->site_htmlvar_name]); ?>' id="sminsite_htmlvar_name;?>" name='sminsite_htmlvar_name;?>' value=''> ' id="smaxsite_htmlvar_name;?>" name='smaxsite_htmlvar_name;?>' value=''>search_condition=='SINGLE' &&$taxonomy_obj->site_htmlvar_name=='event'){ $smincustom_value = @esc_attr($_REQUEST[$taxonomy_obj->site_htmlvar_name.'_start']); ?>search_condition=='FROM' &&$taxonomy_obj->site_htmlvar_name=='event'){ $smincustom_value = @esc_attr($_REQUEST[$taxonomy_obj->site_htmlvar_name.'_start']); $smaxcustom_value = @esc_attr($_REQUEST[$taxonomy_obj->site_htmlvar_name.'_end']); ?>' class='cat_input' id="site_htmlvar_name; ?>_start" name="site_htmlvar_name; ?>_start" field_type="text" /> ' class='cat_input' id="site_htmlvar_name; ?>_end" name="site_htmlvar_name; ?>_end" field_type="text" />field_site_type) && ($taxonomy_obj->field_site_type == 'checkbox')){ $checked = ''; if($geodir_search_custom_value_str == '1') $checked = 'checked="checked"'; echo ''.__('Yes', GEODIRADVANCESEARCH_TEXTDOMAIN).' '; }else{ echo ''; } } endforeach; echo $geodir_search_field_end; if ( ( $increment - 1 ) > $moreoption && !empty( $moreoption ) && $moreoption > 0 ) { echo ''; } echo ''; if(!empty($taxonomy_obj->field_desc)) echo " "; } echo '
- {$taxonomy_obj->field_desc}