function wpestate_ajax_filter_listings_search_onthemap() { global $post; global $current_user; global $options; global $show_compare_only; global $currency; global $where_currency; global $listing_type; $listing_type = get_option('wp_estate_listing_unit_type', ''); $show_compare_only = 'no'; get_currentuserinfo(); $userID = $current_user->ID; $user_option = 'favorites' . $userID; $curent_fav = get_option($user_option); $currency = esc_html(get_option('wp_estate_currency_symbol', '')); $where_currency = esc_html(get_option('wp_estate_where_currency_symbol', '')); $area_array = ''; $city_array = ''; $action_array = ''; $categ_array = ''; $options = wpestate_page_details(intval($_POST['postid'])); $allowed_html = array(); ////////////////////////////////////////////////////////////////////////////////////// ///// category filters ////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['category_values']) && trim($_POST['category_values']) != 'all') { $taxcateg_include = sanitize_title(wp_kses($_POST['category_values'], $allowed_html)); $categ_array = array('taxonomy' => 'property_category', 'field' => 'slug', 'terms' => $taxcateg_include); } ////////////////////////////////////////////////////////////////////////////////////// ///// action filters ////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['action_values']) && trim($_POST['action_values']) != 'all') { $taxaction_include = sanitize_title(wp_kses($_POST['action_values'], $allowed_html)); $action_array = array('taxonomy' => 'property_action_category', 'field' => 'slug', 'terms' => $taxaction_include); } ////////////////////////////////////////////////////////////////////////////////////// ///// city filters ////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['city']) && trim($_POST['city']) != 'all' && $_POST['city'] != '') { $taxcity[] = sanitize_title(wp_kses($_POST['city'], $allowed_html)); $city_array = array('taxonomy' => 'property_city', 'field' => 'slug', 'terms' => $taxcity); } if (isset($_POST['area']) && trim($_POST['area']) != 'all' && $_POST['area'] != '') { $taxarea[] = sanitize_title(wp_kses($_POST['area'], $allowed_html)); $area_array = array('taxonomy' => 'property_area', 'field' => 'slug', 'terms' => $taxarea); } $meta_query = $rooms = $baths = $price = array(); if (isset($_POST['advanced_rooms']) && is_numeric($_POST['advanced_rooms']) && intval($_POST['advanced_rooms'] != 0)) { $rooms['key'] = 'property_rooms'; $rooms['value'] = floatval($_POST['advanced_rooms']); $meta_query[] = $rooms; } if (isset($_POST['advanced_bath']) && is_numeric($_POST['advanced_bath']) && intval($_POST['advanced_bath'] != 0)) { $baths['key'] = 'property_bathrooms'; $baths['value'] = floatval($_POST['advanced_bath']); $meta_query[] = $baths; } if (isset($_POST['advanced_beds']) && is_numeric($_POST['advanced_beds']) && intval($_POST['advanced_beds'] != 0)) { $beds['key'] = 'property_bedrooms'; $beds['value'] = floatval($_POST['advanced_beds']); $meta_query[] = $beds; } if (isset($_POST['guest_no']) && is_numeric($_POST['guest_no']) && intval($_POST['guest_no']) != 0) { $guest['key'] = 'guest_no'; $guest['value'] = floatval($_POST['guest_no']); $guest['type'] = 'numeric'; $guest['compare'] = '>='; $meta_query[] = $guest; } $country_array = array(); if (isset($_POST['country']) && $_POST['country'] != '') { $country = wp_kses($_POST['country'], $allowed_html); $country = str_replace('-', ' ', $country); $country_array['key'] = 'property_country'; $country_array['value'] = $country; $country_array['type'] = 'CHAR'; $country_array['compare'] = 'LIKE'; $meta_query[] = $country_array; } ////////////////////////////////////////////////////////////////////////////////////// ///// chekcers ////////////////////////////////////////////////////////////////////////////////////// $all_checkers = explode(",", $_POST['all_checkers']); foreach ($all_checkers as $cheker) { if ($cheker != '') { $check_array = array(); $check_array['key'] = $cheker; $check_array['value'] = 1; $check_array['compare'] = 'CHAR'; $meta_query[] = $check_array; } } ////////////////////////////////////////////////////////////////////////////////////// ///// price filters ////////////////////////////////////////////////////////////////////////////////////// $price_low = ''; if (isset($_POST['price_low'])) { $price_low = intval($_POST['price_low']); } $price_max = ''; if (isset($_POST['price_max']) && is_numeric($_POST['price_max'])) { $price_max = intval($_POST['price_max']); $price['key'] = 'property_price'; $custom_fields = get_option('wp_estate_multi_curr', true); if (!empty($custom_fields) && isset($_COOKIE['my_custom_curr']) && isset($_COOKIE['my_custom_curr_pos']) && isset($_COOKIE['my_custom_curr_symbol']) && $_COOKIE['my_custom_curr_pos'] != -1) { $i = intval($_COOKIE['my_custom_curr_pos']); if ($price_low != 0) { $price_low = $price_low / $custom_fields[$i][2]; } if ($price_max != 0) { $price_max = $price_max / $custom_fields[$i][2]; } } $price['value'] = array($price_low, $price_max); $price['type'] = 'numeric'; $price['compare'] = 'BETWEEN'; $meta_query[] = $price; } ////////////////////////////////////////////////////////////////////////////////////// ///// calendar filters ////////////////////////////////////////////////////////////////////////////////////// $allowed_html = array(); $book_from = ''; $book_to = ''; if (isset($_POST['check_in'])) { $book_from = wp_kses($_POST['check_in'], $allowed_html); } if (isset($_POST['check_out'])) { $book_to = wp_kses($_POST['check_out'], $allowed_html); } ////////////////////////////////////////////////////////////////////////////////////// ///// order details ////////////////////////////////////////////////////////////////////////////////////// $meta_order = 'prop_featured'; $meta_directions = 'DESC'; if (isset($_POST['order'])) { $order = wp_kses($_POST['order'], $allowed_html); switch ($order) { case 1: $meta_order = 'property_price'; $meta_directions = 'DESC'; break; case 2: $meta_order = 'property_price'; $meta_directions = 'ASC'; break; case 3: $meta_order = 'property_size'; $meta_directions = 'DESC'; break; case 4: $meta_order = 'property_size'; $meta_directions = 'ASC'; break; case 5: $meta_order = 'property_bedrooms'; $meta_directions = 'DESC'; break; case 6: $meta_order = 'property_bedrooms'; $meta_directions = 'ASC'; break; } } $paged = intval($_POST['newpage']); $prop_no = intval(get_option('wp_estate_prop_no', '')); //////////////////////////////////////////////////////////////////////////// // if we have check in and check out dates we need to double loop //////////////////////////////////////////////////////////////////////////// if ($book_from != '' && $book_from != '') { $args = array('cache_results' => false, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'post_type' => 'estate_property', 'post_status' => 'publish', 'posts_per_page' => '-1', 'meta_key' => 'prop_featured', 'orderby' => 'meta_value', 'meta_query' => $meta_query, 'tax_query' => array('relation' => 'AND', $categ_array, $action_array, $city_array, $area_array)); $prop_selection = new WP_Query($args); $right_array = array(); $right_array[] = 0; while ($prop_selection->have_posts()) { $prop_selection->the_post(); // print '</br>we check '.$post->ID.'</br>'; if (wpestate_check_booking_valability($book_from, $book_to, $post->ID)) { $right_array[] = $post->ID; } } wp_reset_postdata(); $args = array('cache_results' => false, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'post_type' => 'estate_property', 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => $prop_no, 'post__in' => $right_array); //print_r($args); $prop_selection = new WP_Query($args); } else { $args = array('cache_results' => false, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'post_type' => 'estate_property', 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => $prop_no, 'meta_key' => 'prop_featured', 'orderby' => 'meta_value', 'meta_query' => $meta_query, 'tax_query' => array('relation' => 'AND', $categ_array, $action_array, $city_array, $area_array)); $prop_selection = new WP_Query($args); } $counter = 0; $compare_submit = wpestate_get_compare_link(); $markers = array(); $return_string = ''; ob_start(); print '<span id="scrollhere"></span>'; /* if( !is_tax() ){ print '<div class="compare_ajax_wrapper">'; get_template_part('templates/compare_list'); print'</div>'; }*/ $listing_unit_style_half = get_option('wp_estate_listing_unit_style_half', ''); if ($prop_selection->have_posts()) { while ($prop_selection->have_posts()) { $prop_selection->the_post(); if ($listing_unit_style_half == 1) { get_template_part('templates/property_unit_wide'); } else { get_template_part('templates/property_unit'); } $markers[] = wpestate_pin_unit_creation(get_the_ID(), $currency, $where_currency, $counter); } kriesi_pagination_ajax($prop_selection->max_num_pages, $range = 2, $paged, 'pagination_ajax_search_home'); } else { print '<span class="no_results">' . esc_html__("We didn't find any results", "wpestate") . '</>'; } // print '</div>'; $templates = ob_get_contents(); ob_end_clean(); $return_string .= '<div class="half_map_results">' . $prop_selection->found_posts . ' ' . esc_html__(' Results found!', 'wpestate') . '</div>'; $return_string .= $templates; echo json_encode(array('added' => true, 'arguments' => json_encode($args), 'markers' => json_encode($markers), 'response' => $return_string)); die; }
<?php // Template Name: Advanced Search Results // Wp Estate Pack get_header(); get_currentuserinfo(); $options = wpestate_page_details($post->ID); $show_compare = 1; $area_array = ''; $city_array = ''; $action_array = ''; $categ_array = ''; $compare_submit = wpestate_get_compare_link(); $currency = esc_html(get_option('wp_estate_currency_symbol', '')); $where_currency = esc_html(get_option('wp_estate_where_currency_symbol', '')); $prop_no = intval(get_option('wp_estate_prop_no', '')); $show_compare_link = 'yes'; $userID = $current_user->ID; $user_option = 'favorites' . $userID; $curent_fav = get_option($user_option); $custom_advanced_search = get_option('wp_estate_custom_advanced_search', ''); $meta_query = array(); $adv_search_what = ''; $adv_search_how = ''; $adv_search_label = ''; $adv_search_type = ''; $book_from = ''; $book_to = ''; $allowed_html = array(); if (isset($_GET['check_in'])) { $book_from = wp_kses($_GET['check_in'], $allowed_html);