format('m/d/Y');
$eagle_booking_checkout = DateTime::createFromFormat("m-d-Y", $eagle_booking_checkout)->format('m/d/Y');
// Booking Dates
$eagle_booking_dates = eagle_booking_displayd_date_format($eagle_booking_checkin). ' ' .' ' .' → '. ' ' .' ' .eagle_booking_displayd_date_format($eagle_booking_checkout);
// Booking Nights
$eagle_booking_nights = eb_total_booking_nights($eagle_booking_checkin, $eagle_booking_checkout);
}
if ( isset( $_GET['eb_view']) && $_GET['eb_view'] === 'grid' ) {
$eb_rooms_view = 'grid-view';
} else {
$eb_rooms_view = 'list-view';
}
/* --------------------------------------------------------------------------
* DEFAULT QUERRY
---------------------------------------------------------------------------*/
$eagle_booking_paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1 ;
$args = array(
'post_type' => 'eagle_rooms',
'post_status' => 'publish',
'posts_per_page' => $eagle_booking_rooms_per_page,
'meta_query' => array(
// Min Price
array(
'key' => 'eagle_booking_mtb_room_price_min',
'type' => 'numeric',
'value' => $eagle_booking_price_range_min,
'compare' => '>=',
),
// Max Price
array(
'key' => 'eagle_booking_mtb_room_price_min',
'type' => 'numeric',
'value' => $eagle_booking_price_range_max,
'compare' => '<=',
),
// Exclude
array(
'key' => 'eagle_booking_mtb_room_excluded',
'compare' => 'NOT EXISTS',
),
),
'paged' => $eagle_booking_paged
);
if ( eb_get_option('eb_adults_children') == true ) {
// Adults
$args['meta_query'][] = array(
'key' => 'eagle_booking_mtb_room_max_adults',
'type' => 'numeric',
'value' => $eagle_booking_adults,
'compare' => '>='
);
// Children
$args['meta_query'][] = array(
'key' => 'eagle_booking_mtb_room_max_children',
'type' => 'numeric',
'value' => $eagle_booking_children,
'compare' => '>='
);
} else {
// Guests
$args['meta_query'][] = array(
'key' => 'eagle_booking_mtb_room_maxguests',
'type' => 'numeric',
'value' => $eagle_booking_guests,
'compare' => '>='
);
}
// Branch
if( isset( $_GET['eb_branch'] ) && $_GET['eb_branch'] != 'all' ) {
$eb_selected_branch = $_GET['eb_branch'];
$args['tax_query'][] = array(
'taxonomy' => 'eagle_branch',
'field' => 'term_id',
'terms' => $eb_selected_branch,
);
} else {
$eb_selected_branch = '';
}
$the_query = new WP_Query( $args );
// Pagination
$eagle_booking_results_qnt = $the_query->found_posts;
$eagle_booking_qnt_pagination = ceil($eagle_booking_results_qnt / $eagle_booking_rooms_per_page);
?>
wp_create_nonce( 'eb_nonce' ),
)
);
// Clean Buffer
return ob_get_clean();
}
// Depracated Shortcode (Will be removed soon)
add_shortcode('eagle_booking_search_results', 'eb_search_page_shortcode');
// Search Page Shotcode
add_shortcode('eb_search', 'eb_search_page_shortcode');
function eagle_booking_filters() {
// Check Nonce
if ( !check_ajax_referer('eb_nonce', 'eb_search_filters_nonce', false) ) { ?>
'eagle_rooms',
'post_status' => 'publish',
'post__not_in' => array(),
'posts_per_page' => $eagle_booking_rooms_per_page,
'orderby' => $eagle_booking_booking_order_by,
'meta_key' => $eagle_booking_search_sorting_filter_meta_key,
'order' => $eagle_booking_booking,
'suppress_filters' => false,
'meta_query' => array(
// Min Price
array(
'key' => 'eagle_booking_mtb_room_price_min',
'type' => 'numeric',
'value' => $eagle_booking_price_range_min,
'compare' => '>=',
),
// Max Price
array(
'key' => 'eagle_booking_mtb_room_price_min',
'type' => 'numeric',
'value' => $eagle_booking_price_range_max,
'compare' => '<=',
),
// Exclude
array(
'key' => 'eagle_booking_mtb_room_excluded',
'compare' => 'NOT EXISTS',
),
),
'paged' => $eagle_booking_paged
);
if ( eb_get_option('eb_adults_children') == true ) {
// Adults
$args['meta_query'][] = array(
'key' => 'eagle_booking_mtb_room_max_adults',
'type' => 'numeric',
'value' => $eagle_booking_adults,
'compare' => '>='
);
// Children
$args['meta_query'][] = array(
'key' => 'eagle_booking_mtb_room_max_children',
'type' => 'numeric',
'value' => $eagle_booking_children,
'compare' => '>='
);
} else {
// Guests
$args['meta_query'][] = array(
'key' => 'eagle_booking_mtb_room_maxguests',
'type' => 'numeric',
'value' => $eagle_booking_guests,
'compare' => '>='
);
}
/* --------------------------------------------------------------------------
* Normal Services Filter
---------------------------------------------------------------------------*/
if ( $eb_normal_services ) {
$eb_normal_services_array = explode(',', $eb_normal_services);
for ( $eb_normal_services_i = 0; $eb_normal_services_i < count($eb_normal_services_array); $eb_normal_services_i++ ) {
$eb_normal_room_service = get_post( $eb_normal_services_array[$eb_normal_services_i], OBJECT, 'eagle_services' );
if( is_object( $eb_normal_room_service ) ) {
$eb_normal_service_id = $eb_normal_room_service->ID;
$args ['meta_query'][] = array(
'key' => 'eagle_booking_mtb_room_services',
'value' => $eb_normal_service_id,
'compare' => 'LIKE',
);
}
}
}
/* --------------------------------------------------------------------------
* Additional Services Filter
---------------------------------------------------------------------------*/
if ( $eb_additional_services ) {
$eb_additional_services_array = explode(',', $eb_additional_services);
for ($eb_additional_services_i = 0; $eb_additional_services_i < count($eb_additional_services_array); $eb_additional_services_i++) {
$eb_room_additional_service = get_post( $eb_additional_services_array[$eb_additional_services_i], OBJECT, 'eagle_services' );
if( is_object( $eb_room_additional_service ) ) {
$eb_additional_service_id = $eb_room_additional_service->ID;
$args['meta_query'][] = array(
'key' => 'eagle_booking_mtb_room_additional_services',
'value' => $eb_additional_service_id,
'compare' => 'LIKE',
);
}
}
}
/* --------------------------------------------------------------------------
* Branches Filter
---------------------------------------------------------------------------*/
if ( $eb_branch_id ) {
$args['tax_query'][] = array(
'taxonomy' => 'eagle_branch',
'field' => 'term_id',
'terms' => $eb_branch_id,
);
}
// Add all args to the query
$the_query = new WP_Query($args);
// Pagination
$eagle_booking_results_qnt = $the_query->found_posts;
$eagle_booking_qnt_pagination = ceil($eagle_booking_results_qnt / $eagle_booking_rooms_per_page);
?>
have_posts()) : $the_query->the_post();
/**
* Include Room
*/
include eb_load_template('search/room.php');
endwhile;
/**
* Include Pagination
*/
include eb_load_template('search/pagination.php');
?>