// 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', 'order' => 'DESC', 'meta_query' => $meta_query, 'tax_query' => array('relation' => 'AND', $categ_array, $action_array, $city_array, $area_array));
    $custom_fields = get_option('wp_estate_custom_fields', true);
    add_filter('posts_orderby', 'wpestate_my_order');
    $prop_selection = new WP_Query($args);
    remove_filter('posts_orderby', 'wpestate_my_order');
    $num = $prop_selection->found_posts;
    //print_r($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', 'order' => 'DESC', 'meta_query' => $meta_query, 'tax_query' => array('relation' => 'AND', $categ_array, $action_array, $city_array, $area_array));
    $prop_selection = new WP_Query($args);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// map pins
///////////////////////////////////////////////////////////////////////////////////////////////////
if (is_page_template('advanced_search_results.php') && $book_from != '' && $book_from != '') {
Ejemplo n.º 2
0
 function wpestate_ajax_filter_listings_search_on_main_map()
 {
     global $post;
     global $current_user;
     global $options;
     global $show_compare_only;
     global $currency;
     global $where_currency;
     $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 = '';
     $allowed_html = array();
     $meta_query = array();
     //////////////////////////////////////////////////////////////////////////////////////
     ///// 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);
     }
     $guest_array = array();
     if (isset($_POST['guest_no']) && is_numeric($_POST['guest_no'])) {
         $guest_no = intval($_POST['guest_no']);
         $guest_array['key'] = 'guest_no';
         $guest_array['value'] = $guest_no;
         $guest_array['type'] = 'numeric';
         $guest_array['compare'] = '>=';
         $meta_query[] = $guest_array;
     }
     $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;
     }
     //////////////////////////////////////////////////////////////////////////////////////
     ///// calendar filters
     //////////////////////////////////////////////////////////////////////////////////////
     $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
     //////////////////////////////////////////////////////////////////////////////////////
     $args = array('post_type' => 'estate_property', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => $meta_query, 'tax_query' => array('relation' => 'AND', $categ_array, $action_array, $city_array, $area_array));
     // print_r($args);
     $prop_selection = new WP_Query($args);
     $counter = 0;
     $markers = array();
     while ($prop_selection->have_posts()) {
         $prop_selection->the_post();
         if (wpestate_check_booking_valability($book_from, $book_to, $post->ID)) {
             $counter++;
             $markers[] = wpestate_pin_unit_creation(get_the_ID(), $currency, $where_currency, $counter);
         }
     }
     //print 'resutls '.$counter;
     echo json_encode(array('added' => true, 'arguments' => json_encode($args), 'markers' => json_encode($markers), 'counter' => $counter));
     die;
 }
Ejemplo n.º 3
0
 function wpestate_listing_pins_with_reservation($args = '', $jump = 0, $book_from, $book_to)
 {
     wp_suspend_cache_addition(true);
     set_time_limit(0);
     $counter = 0;
     $unit = get_option('wp_estate_measure_sys', '');
     $currency = get_option('wp_estate_currency_symbol', '');
     $where_currency = get_option('wp_estate_where_currency_symbol', '');
     $cache = get_option('wp_estate_cache', '');
     $place_markers = array();
     $markers = array();
     if ($cache == 'yes') {
         if (!get_transient('prop_list_cached')) {
             if ($args == '') {
                 $args = array('post_type' => 'estate_property', 'post_status' => 'publish', 'nopaging' => 'true', 'cache_results' => false, 'update_post_meta_cache' => false, 'update_post_term_cache' => false);
             }
             $prop_selection = new WP_Query($args);
             set_transient('prop_list_cached', $prop_selection, 60 * 60 * 3);
             //store data for 3h
         } else {
             $prop_selection = get_transient('prop_list_cached');
             // retrive cached data
         }
         wp_reset_query();
     } else {
         if ($args == '') {
             $args = array('post_type' => 'estate_property', 'post_status' => 'publish', 'nopaging' => 'true', 'cache_results' => false, 'update_post_meta_cache' => false, 'update_post_term_cache' => false);
         }
         $prop_selection = new WP_Query($args);
         wp_reset_query();
     }
     //end cache
     $custom_advanced_search = get_option('wp_estate_custom_advanced_search', '');
     $show_slider_price = get_option('wp_estate_show_slider_price', '');
     $has_slider = 0;
     while ($prop_selection->have_posts()) {
         $prop_selection->the_post();
         $counter++;
         if (wpestate_check_booking_valability($book_from, $book_to, get_the_ID())) {
             $markers[] = wpestate_pin_unit_creation(get_the_ID(), $currency, $where_currency, $counter);
         }
         //    print_r($place_markers)  ;
     }
     wp_reset_query();
     wp_suspend_cache_addition(false);
     if (get_option('wp_estate_readsys', '') == 'yes' && $jump == 0) {
         $path = get_template_directory() . '/pins.txt';
         wpestate_otto_write_tofile($path, json_encode($markers));
     } else {
         return json_encode($markers);
     }
 }