1,
'required_max_nights' => 999,
];
$eshb_min_max_settings = apply_filters( 'eshb_min_max_global_settings_in_searach', $min_max_settings);
$required_min_nights = !empty($eshb_min_max_settings['required_min_nights']) ? $eshb_min_max_settings['required_min_nights'] : 1;
$required_max_nights = !empty($eshb_min_max_settings['required_max_nights']) ? $eshb_min_max_settings['required_max_nights'] : '';
$today_date = gmdate('Y-m-d'); // Get today's date
// Create a DateTime object from today's date
$date = new DateTime($today_date);
// Add one day
$date->modify('+'.$required_min_nights.' day');
// Get the new date in 'Y-m-d' format
$end_date = $date->format('Y-m-d');
}
$eshb_settings = get_option( 'eshb_settings' );
$search_result_page_id = $eshb_settings['search-result-page'];
if(empty($search_result_page_id)) {
// get id by page slug
$search_result_page = get_page_by_path('easy-hotel-search-result');
if($search_result_page){
$search_result_page_id = $search_result_page->ID;
}
}
if ( ! empty( $search_result_page_id ) ) {
if ( function_exists( 'pll_get_post' ) ) {
$translated_id = pll_get_post( $search_result_page_id );
if ( ! empty( $translated_id ) ) {
$search_result_page_id = $translated_id;
}
} elseif ( function_exists( 'icl_object_id' ) ) {
$translated_id = icl_object_id( $search_result_page_id, 'page', true );
if ( ! empty( $translated_id ) ) {
$search_result_page_id = $translated_id;
}
}
}
$search_result_page_url = !empty($search_result_page_id) ? get_the_permalink( $search_result_page_id ) : site_url( '/easy-hotel-search-result' );
$seach_form_fileds = isset($eshb_settings['search-form-fields']) && !empty($eshb_settings['search-form-fields']) ? $eshb_settings['search-form-fields'] : [];
$adult_capacity = isset($eshb_settings['adult-capacity']) && !empty($eshb_settings['adult-capacity']) ? $eshb_settings['adult-capacity'] : 1000;
$children_capacity = isset($eshb_settings['children-capacity']) && !empty($eshb_settings['children-capacity']) ? $eshb_settings['children-capacity'] : 1000;
$min_adult_quantity = isset($eshb_settings['min-adult-capacity']) && !empty($eshb_settings['min-adult-capacity']) ? $eshb_settings['min-adult-capacity'] : 1;
$min_children_quantity = isset($eshb_settings['min-children-capacity']) && !empty($eshb_settings['min-children-capacity']) ? $eshb_settings['min-children-capacity'] : 0;
$room_capacity = isset($eshb_settings['room-capacity']) && !empty($eshb_settings['room-capacity']) ? $eshb_settings['room-capacity'] : 1000;
// Translations
$string_check_availability = isset($eshb_settings['string_check_availability']) && !empty($eshb_settings['string_check_availability']) ? $eshb_settings['string_check_availability'] : 'Check Availability';
$string_check_in = isset($eshb_settings['string_check_in']) && !empty($eshb_settings['string_check_in']) ? $eshb_settings['string_check_in'] : 'Check In';
$string_check_out = isset($eshb_settings['string_check_out']) && !empty($eshb_settings['string_check_out']) ? $eshb_settings['string_check_out'] : 'Check Out';
$string_adult = isset($eshb_settings['string_adult']) && !empty($eshb_settings['string_adult']) ? $eshb_settings['string_adult'] : 'Adult';
$string_children = isset($eshb_settings['string_children']) && !empty($eshb_settings['string_children']) ? $eshb_settings['string_children'] : 'Children';
$string_room = isset($eshb_settings['string_room']) && !empty($eshb_settings['string_room']) ? $eshb_settings['string_room'] : 'Room';
$has_search_calendar_icon = isset($eshb_settings['search-form-calendar-icon']) && !empty($eshb_settings['search-form-calendar-icon']) ? true : false;
?>
format('w'); // 0 = Sunday, 1 = Monday, ..., 6 = Saturday
$daysOfWeek = [
"sunday" => 0, "monday" => 1, "tuesday" => 2, "wednesday" => 3,
"thursday" => 4, "friday" => 5, "saturday" => 6
];
if (!isset($daysOfWeek[strtolower($allowedDays[0])])) {
return false;
}
$targetDay = $daysOfWeek[strtolower($allowedDays[0])];
if ($dayOfWeek !== $targetDay) {
$daysToAdd = ($targetDay - $dayOfWeek + 7) % 7 ?: 7;
$givenDate->modify("+$daysToAdd days");
}
return $givenDate->format('Y-m-d');
}
public function eshb_get_booking_form_html($accomodation_id = null, $style = 'style-one', $form_attr = array()){
$form_attr_html = '';
if ( is_array( $form_attr ) ) {
foreach ( $form_attr as $attr_key => $attr_value ) {
$form_attr_html .= ' ' . esc_attr( $attr_key ) . '="' . esc_attr( $attr_value ) . '"';
}
}
if(is_singular( 'eshb_accomodation' ) && ($accomodation_id == null || empty($accomodation_id))){
$accomodation_id = get_the_ID();
}
if($accomodation_id == null || empty($accomodation_id)){
return 'invalid accomodation';
}
$eshb_settings = get_option( 'eshb_settings' );
$booking_type = isset($eshb_settings['booking-type']) && !empty($eshb_settings['booking-type']) ? $eshb_settings['booking-type'] : 'woocommerce';
$booking_form_type = isset($eshb_settings['booking-form-type']) && !empty($eshb_settings['booking-form-type']) ? $eshb_settings['booking-form-type'] : 'default';
if($booking_type != 'booking_request'){
$booking_form_type = 'default';
}
global $woocommerce;
$style_class = $style;
$hotel_core = new ESHB_Core();
$currency_symbol = $hotel_core->get_eshb_currency_symbol();
$accomodation_metaboxes = get_post_meta($accomodation_id, 'eshb_accomodation_metaboxes', true);
$min_max_nights_settings = [
'required_min_nights' => 1,
'required_max_nights' => 999,
];
$min_max_nights_settings = apply_filters('eshb_min_max_nights_settings_before_search', $min_max_nights_settings, $accomodation_id, $accomodation_metaboxes);
$required_min_nights = !empty($min_max_nights_settings['required_min_nights']) ? $min_max_nights_settings['required_min_nights'] : 1;
$required_max_nights = !empty($min_max_nights_settings['required_max_nights']) ? $min_max_nights_settings['required_max_nights'] : 999;
$calendar_start_date_buffer = !empty($eshb_min_max_settings['calendar_start_date_buffer']) ? $eshb_min_max_settings['calendar_start_date_buffer'] : 0;
$today_date = gmdate('Y-m-d');
$today_date = gmdate( 'Y-m-d', strtotime($today_date . ' +' . $calendar_start_date_buffer . ' day')); // Get today's date
// Create a DateTime object from today's date
$date = new DateTime($today_date);
// Add one day
$date->modify('+'.$required_min_nights.' day');
// Get the new date in 'Y-m-d' format
$tomorrow = $date->format('Y-m-d');
$room_visibility = in_array('rooms', $eshb_settings['booking-form-fields']) ? true : false;
$adult_capacity = !empty($accomodation_metaboxes['adult_capacity']) ? $accomodation_metaboxes['adult_capacity'] : 1;
$children_capacity = !empty($accomodation_metaboxes['children_capacity']) ? $accomodation_metaboxes['children_capacity'] : 0;
$min_adult_quantity = !empty($eshb_settings['booking-min-adult-capacity']) ? $eshb_settings['booking-min-adult-capacity'] : 1;
$min_children_quantity = !empty($eshb_settings['booking-min-children-capacity']) ? $eshb_settings['booking-min-children-capacity'] : 0;
$room_capacity = !empty($accomodation_metaboxes['total_rooms']) ? $accomodation_metaboxes['total_rooms'] : 1;
$is_single_day_plugin_active = get_option('eshb_single_day_activated');
$pricing_periodicity = false;
$single_day_price = apply_filters( 'eshb_single_day_price', 0, $accomodation_id );
if ($is_single_day_plugin_active && $single_day_price) {
$pricing_periodicity = !empty($accomodation_metaboxes['pricing_periodicity']) ? $accomodation_metaboxes['pricing_periodicity'] : false;
}
// Verify nonce for security
if (isset($_GET['nonce']) && wp_verify_nonce( sanitize_text_field(wp_unslash($_GET['nonce'])), ESHB_Helper::generate_secure_nonce_action('eshb_global_nonce_action'))) {
$start_date = isset( $_GET['start_date'] ) && !empty($_GET['start_date']) ? sanitize_text_field( wp_unslash($_GET['start_date'] )) : $today_date;
$end_date = isset( $_GET['end_date'] ) && !empty($_GET['end_date']) ? sanitize_text_field( wp_unslash($_GET['end_date'] )) : $tomorrow;
$adult_quantity = isset( $_GET['adult_quantity'] ) && !empty($_GET['adult_quantity']) ? sanitize_text_field( wp_unslash($_GET['adult_quantity'] )) : 1;
$children_quantity = isset( $_GET['children_quantity'] ) && !empty($_GET['children_quantity']) ? sanitize_text_field( wp_unslash($_GET['children_quantity'] )) : 0;
$adult_quantity = $adult_quantity > $adult_capacity ? $adult_capacity : $adult_quantity;
$children_quantity = $children_quantity > $children_capacity ? $children_capacity : $children_quantity;
$room_quantity = isset( $_GET['room_quantity'] ) && !empty($_GET['room_quantity']) ? sanitize_text_field( wp_unslash($_GET['room_quantity'] )) : 1;
$room_quantity = $room_quantity > $room_capacity ? $room_capacity : $room_quantity;
}else{
$start_date = $today_date;
$end_date = $tomorrow;
$adult_quantity = 1;
$children_quantity = 0;
$room_quantity = 1;
}
$adult_quantity = $adult_quantity > $adult_capacity ? $adult_capacity : $adult_quantity;
$children_quantity = $children_quantity > $children_capacity ? $children_capacity : $children_quantity;
$adult_quantity = $adult_quantity < $min_adult_quantity ? $min_adult_quantity : $adult_quantity;
$children_quantity = $children_quantity < $min_children_quantity ? $min_children_quantity : $children_quantity;
// set end to same as start date for single day hourly booking
if($pricing_periodicity == 'per_hour') {
$end_date = $start_date;
}
$start = new DateTime($start_date);
$end = new DateTime($end_date);
$interval = $start->diff($end);
$days_count = $interval->days;
$allowed_check_in_day = isset($accomodation_metaboxes['allowed_check_in_day']) && !empty($accomodation_metaboxes['allowed_check_in_day']) ? $accomodation_metaboxes['allowed_check_in_day'] : [];
if(!empty($allowed_check_in_day)){
// push the day to array if its string
if(is_string($allowed_check_in_day)){
$allowed_check_in_day = [$allowed_check_in_day];
}
$allowed_check_in_day = array_map('strtolower', $allowed_check_in_day);
// Add 1 day to get the next allowed end date
$next_allowed_start_date = $this->getNextAllowedStartDate($allowed_check_in_day, $start_date);
if(!empty($next_allowed_start_date) && !empty($next_allowed_end_date)){
$start_date = $next_allowed_start_date;
//$end_date = $next_allowed_end_date;
}
}
$currency_symbol = $hotel_core->get_eshb_currency_symbol();
$per_night_price_html = $hotel_core->get_eshb_price_html('', '', $accomodation_id, true, false, true, true);
$price_html = $hotel_core->get_eshb_price_html($start_date, $end_date, $accomodation_id, true, false, true, true, 'regular');
$price = $hotel_core->get_eshb_price_html($start_date, $end_date, $accomodation_id, false, true, true, false);
$price = !empty($price) ? $price : 0;
// discounted pricing
$discountedPrice = $hotel_core->get_eshb_price_html($start_date, $end_date, $accomodation_id, false, true, true, true);
$discountedPrice = !empty($discountedPrice) ? $discountedPrice : 0;
$booking_form_fileds = $eshb_settings['booking-form-fields'];
$external_booking_link = isset($eshb_settings['external-booking-link']) && !empty($eshb_settings['external-booking-link']) ? $eshb_settings['external-booking-link'] : false;
// Translations
$string_reserve = isset($eshb_settings['string_reserve']) && !empty($eshb_settings['string_reserve']) ? $eshb_settings['string_reserve'] : 'Reserve';
$string_from = isset($eshb_settings['string_from']) && !empty($eshb_settings['string_from']) ? $eshb_settings['string_from'] : 'From';
$string_night = isset($eshb_settings['string_night']) && !empty($eshb_settings['string_night']) ? $eshb_settings['string_night'] : 'night';
$string_hour = isset($eshb_settings['string_hour']) && !empty($eshb_settings['string_hour']) ? $eshb_settings['string_hour'] : 'hour';
$string_check_in = isset($eshb_settings['string_check_in']) && !empty($eshb_settings['string_check_in']) ? $eshb_settings['string_check_in'] : 'Check In';
$string_check_out = isset($eshb_settings['string_check_out']) && !empty($eshb_settings['string_check_out']) ? $eshb_settings['string_check_out'] : 'Check Out';
$string_adult = isset($eshb_settings['string_adult']) && !empty($eshb_settings['string_adult']) ? $eshb_settings['string_adult'] : 'Adult';
$string_children = isset($eshb_settings['string_children']) && !empty($eshb_settings['string_children']) ? $eshb_settings['string_children'] : 'Children';
$string_rooms = isset($eshb_settings['string_rooms']) && !empty($eshb_settings['string_rooms']) ? $eshb_settings['string_rooms'] : 'Rooms';
$string_available_rooms = isset($eshb_settings['available_rooms']) && !empty($eshb_settings['available_rooms']) ? $eshb_settings['available_rooms'] : 'Available Rooms:';
$string_extra_bed = isset($eshb_settings['string_extra_bed']) && !empty($eshb_settings['string_extra_bed']) ? $eshb_settings['string_extra_bed'] : 'Extra Bed';
$string_extra_services = isset($eshb_settings['string_extra_services']) && !empty($eshb_settings['string_extra_services']) ? $eshb_settings['string_extra_services'] : 'Extra Services';
$string_total_cost = isset($eshb_settings['string_total_cost']) && !empty($eshb_settings['string_total_cost']) ? $eshb_settings['string_total_cost'] : 'Total Cost';
$string_disocunted_price = isset($eshb_settings['string_disocunted_price']) && !empty($eshb_settings['string_disocunted_price']) ? $eshb_settings['string_disocunted_price'] : 'Discounted Price';
$string_book_your_stay = isset($eshb_settings['string_book_your_stay']) && !empty($eshb_settings['string_book_your_stay']) ? $eshb_settings['string_book_your_stay'] : 'Book Your Stay';
$string_room = isset($eshb_settings['string_room']) && !empty($eshb_settings['string_room']) ? $eshb_settings['string_room'] : 'room';
$string_guest = isset($eshb_settings['string_guest']) && !empty($eshb_settings['string_guest']) ? $eshb_settings['string_guest'] : 'guest';
$string_time_slots = isset($eshb_settings['string_time_slots']) && !empty($eshb_settings['string_time_slots']) ? $eshb_settings['string_time_slots'] : 'Available Time Slots';
$string_please_wait = isset($eshb_settings['string_please_wait']) && !empty($eshb_settings['string_please_wait']) ? $eshb_settings['string_please_wait'] : 'Please Wait';
$included_service_ids = !empty($accomodation_metaboxes['accomodation_services']) ? $accomodation_metaboxes['accomodation_services'] : [];
$total_rooms = !empty($accomodation_metaboxes['total_rooms']) ? $accomodation_metaboxes['total_rooms'] : 0;
$eshb_bookings = new ESHB_Booking();
$available_rooms = $eshb_bookings->get_available_room_count_by_date_range($accomodation_id, $start->format('Y-m-d'), $end->format('Y-m-d'));
$available_rooms = $available_rooms < 0 ? 0 : $available_rooms;
$available_times = ESHB_Helper::get_available_times_by_date($accomodation_id, $start->format('Y-m-d'));
$price_html = $available_rooms < 1 ? $hotel_core->eshb_price(0) : $price_html;
$defaultExtraServicePrice = 0;
$has_calendar_icon = isset($eshb_settings['booking-form-calendar-icon']) && !empty($eshb_settings['booking-form-calendar-icon']) ? true : false;
$checked_services = [];
foreach($included_service_ids as $service_id){
$service_metaboxes = get_post_meta($service_id, 'eshb_service_metaboxes', true);
$is_checked = isset($service_metaboxes['is_checked']) && !empty($service_metaboxes['is_checked']) ? true : false;
if($is_checked){
$checked_services[] = $service_id;
}
}
$pricing = $eshb_bookings->calculate_booking_pricing(
$accomodation_id,
$start_date,
$end_date,
$room_quantity,
0,
$adult_quantity,
$children_quantity,
$checked_services,
true,
'',
''
);
$price_html = $pricing['totalPriceHtml'];
$regular_total_price_html = $pricing['regularTotalPriceHtml'];
?>
class="eshb-booking-form " data-booking-form-type="" data-pricing-periodicity="">
0 ):?>
/
0){ ?>
0 && $eshb_settings['extra-services-switcher'] == true){ ?>
max_num_pages <= 1 ) {
return;
}
$big = 999999999; // Need an unlikely integer
// Generate pagination links
$pages = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $query->max_num_pages,
'prev_text' => __('« Previous', 'easy-hotel'),
'next_text' => __('Next »', 'easy-hotel'),
'type' => 'array', // Output as array to customize
) );
if ( is_array( $pages ) ) {
echo '';
}
}
public function eshb_get_availability_calendar_html($accomodation_id = null, $style = 'style-one', $show_title = true){
$eshb_settings = get_option('eshb_settings', []);
$availability_calendar_title = isset($eshb_settings['string_availability_calendar']) && !empty($eshb_settings['string_availability_calendar']) ? $eshb_settings['string_availability_calendar'] : __('Availability Calendar', 'easy-hotel');
global $woocommerce;
$style_class = $style;
if( $accomodation_id == null || empty($accomodation_id)){
global $post;
$accomodation_id = $post->ID;
}
$today_date = gmdate('Y-m-d'); // Get today's date
$min_max_settings = [
'calendar_start_date_buffer' => 0,
];
$eshb_min_max_settings = apply_filters( 'eshb_min_max_global_settings_in_searach', $min_max_settings);
$calendar_start_date_buffer = !empty($eshb_min_max_settings['calendar_start_date_buffer']) ? $eshb_min_max_settings['calendar_start_date_buffer'] : 0;
$start_date = $today_date;
// Verify nonce for security
if (isset($_GET['nonce']) && wp_verify_nonce( sanitize_text_field(wp_unslash($_GET['nonce'])), 'eshb_nonce_action')) {
$start_date = isset( $_GET['start_date'] ) && !empty($_GET['start_date']) ? sanitize_text_field( wp_unslash($_GET['start_date'] )) : $today_date;
}
?>
=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`[[^]]*]`','',$excerpt);
return $excerpt;
}
public function eshb_get_gallery_html($accomodation_id = null, $unique_id = '', $thumbnail_size ='full', $sliderDots = 'false', $sliderNav = 'true'){
$eshb_accomodation_metaboxes_side = get_post_meta($accomodation_id, 'eshb_accomodation_metaboxes_side', true);
$accomodation_hero_type = !empty($eshb_accomodation_metaboxes_side['accomodation_hero_type']) ? $eshb_accomodation_metaboxes_side['accomodation_hero_type'] : 'gallery';
$accomodation_gallery = !empty($eshb_accomodation_metaboxes_side['accomodation_gallery']) ? $eshb_accomodation_metaboxes_side['accomodation_gallery'] : '';
$accomodation_video = !empty($eshb_accomodation_metaboxes_side['accomodation_video']) ? $eshb_accomodation_metaboxes_side['accomodation_video'] : '';
$accomodation_video_source = !empty($eshb_accomodation_metaboxes_side['accomodation_video_source']) ? $eshb_accomodation_metaboxes_side['accomodation_video_source'] : '';
$accomodation_gallery_ids = explode( ',', $accomodation_gallery );
$accomodation_gallery_slides_per_view = !empty($eshb_accomodation_metaboxes_side['slides_per_view']) ? $eshb_accomodation_metaboxes_side['slides_per_view'] : '2.1';
$accomodation_video_height = !empty($eshb_accomodation_metaboxes_side['accomodation_video_height']) ? $eshb_accomodation_metaboxes_side['accomodation_video_height'] : 0;
if($accomodation_hero_type != 'video'){
?>
1 && !empty($sliderDots == 'true' || $sliderNav == 'true') ) : ?>
';
?>
ID;
}
$hotel_core = new ESHB_Core();
$accomodation_metaboxes = get_post_meta($accomodation_id, 'eshb_accomodation_metaboxes', true);
$day_wise_price = isset($accomodation_metaboxes['day_wise_price']) && !empty($accomodation_metaboxes['day_wise_price'][0]) ? $accomodation_metaboxes['day_wise_price'][0] : [];
$day_wise_price = array_filter($day_wise_price, function($value) {
return !empty($value) && $value != 0;
});
if (empty($day_wise_price)) {
return; // return if all values are empty or 0
}
$default_price = $hotel_core->get_eshb_price('', '', $accomodation_id, false, true, false, true);
$all_days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
$currency_symbol = $hotel_core->get_eshb_currency_symbol();
?>