?> " method="get"> <div class="inline-fields clearfix"> <?php global $field_counter; $field_counter = 0; foreach ($search_fields as $key => $val) { switch ($key) { case 'keyword': get_template_part('partials/search/fields/keyword'); $field_counter++; break; case 'location': get_template_part('partials/search/fields/locations'); // code to display hidden field separator at right place $number_of_location_boxes = inspiry_get_locations_number(); if ($number_of_location_boxes > 1 && $field_counter < 3) { $field_counter += $number_of_location_boxes; if ($field_counter > 3) { get_template_part('partials/search/hidden-fields-separator'); } } else { $field_counter++; } break; case 'status': get_template_part('partials/search/fields/property-status'); $field_counter++; break; case 'type': get_template_part('partials/search/fields/property-type');
/** * Generates locations related data that is consumed by js to product locations related UI */ function inspiry_generate_location_data() { if (!is_admin()) { // all property city terms $all_locations = get_terms('property-city', array('hide_empty' => false, 'orderby' => 'count', 'order' => 'desc')); // select boxes names $location_select_names = inspiry_get_location_select_names(); $location_select_count = inspiry_get_locations_number(); // location parameters in request, if any $locations_in_params = array(); foreach ($location_select_names as $location_name) { if (isset($_GET[$location_name])) { $locations_in_params[$location_name] = $_GET[$location_name]; } } // combine all data into one array $location_data_array = array('any' => __('(Any)', 'inspiry'), 'all_locations' => $all_locations, 'select_names' => $location_select_names, 'select_count' => $location_select_count, 'locations_in_params' => $locations_in_params); // provide location data array before property search form script wp_localize_script('inspiry-search-form', 'locationData', $location_data_array); } }
<?php global $inspiry_options; // number of locations chosen from theme options $location_select_count = inspiry_get_locations_number(); $location_select_names = inspiry_get_location_select_names(); $location_titles = inspiry_get_location_titles($location_select_count); // override select boxes titles based on theme options data for ($i = 1; $i <= $location_select_count; $i++) { $temp_location_title = $inspiry_options['inspiry_search_location_title_' . $i]; if (!empty($temp_location_title)) { $location_titles[$i - 1] = $temp_location_title; } } // Generate required location select boxes for ($i = 0; $i < $location_select_count; $i++) { ?> <div class="option-bar property-location"> <select name="<?php echo esc_attr($location_select_names[$i]); ?> " id="<?php echo esc_attr($location_select_names[$i]); ?> " data-title="<?php echo esc_attr($location_titles[$i]); ?> " class="search-select"> <option value="any"><?php echo $location_titles[$i] . ' ' . __('(Any)', 'inspiry'); ?>