PluginProbe
Easy Hotel – Powerful Hotel Booking / 2.0.4
Easy Hotel – Powerful Hotel Booking v2.0.4
2.0.8 2.0.7 2.0.6 2.0.5 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.9.9 1.9.8 1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 All 110 releases
easy-hotel / public / includes / classes / class.view.php

class.view.php in Easy Hotel – Powerful Hotel Booking 2.0.4, at public/includes/classes/class.view.php

1,013 lines 61.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3 class ESHB_View extends ESHB_MAIN{
4
5 private static $query = null;
6
7 public function eshb_get_accomodation_grid($query, $adult_quantity = 1, $children_quantity = 0, $column = 3, $thumbnail_size='eshb_thumbnail', $style='style-one', $start_date='', $end_date='', $booked_dates = []){
8
9 if($query != NULL || !empty($query)){
10
11 // Check if the custom template exists in your plugin directory
12 $plugin_template = ESHB_PL_PATH . 'public/templates/template-parts/grid-'.$style. '.php';
13 $theme_template = get_stylesheet_directory() . '/easy-hotel/templates/template-parts/grid-'.$style.'.php';
14 $child_theme_template = get_template_directory() . '/easy-hotel/templates/template-parts/grid-'.$style.'.php';
15
16 if (file_exists($child_theme_template)) {
17 $template = $child_theme_template;
18 } elseif (file_exists($theme_template)) {
19 $template = $theme_template;
20 } else {
21 $template = $plugin_template;
22 }
23
24 include $template;
25 }
26 }
27
28 public function eshb_get_search_form_html($start_date = null, $end_date = null){
29
30
31 if( $start_date == null || empty($start_date) ){
32 $today_date = gmdate('Y-m-d');
33 $start_date = $today_date;
34 }
35
36 if( $end_date == null || empty($end_date) ){
37
38 $min_max_settings = [
39 'required_min_nights' => 1,
40 'required_max_nights' => 999,
41 ];
42 $eshb_min_max_settings = apply_filters( 'eshb_min_max_global_settings_in_searach', $min_max_settings);
43 $required_min_nights = !empty($eshb_min_max_settings['required_min_nights']) ? $eshb_min_max_settings['required_min_nights'] : 1;
44 $required_max_nights = !empty($eshb_min_max_settings['required_max_nights']) ? $eshb_min_max_settings['required_max_nights'] : '';
45
46
47 $today_date = gmdate('Y-m-d'); // Get today's date
48
49 // Create a DateTime object from today's date
50 $date = new DateTime($today_date);
51
52 // Add one day
53 $date->modify('+'.$required_min_nights.' day');
54
55 // Get the new date in 'Y-m-d' format
56 $end_date = $date->format('Y-m-d');
57 }
58
59 $eshb_settings = get_option( 'eshb_settings' );
60 $search_result_page_id = $eshb_settings['search-result-page'];
61
62 if(empty($search_result_page_id)) {
63 // get id by page slug
64 $search_result_page = get_page_by_path('easy-hotel-search-result');
65 if($search_result_page){
66 $search_result_page_id = $search_result_page->ID;
67 }
68 }
69
70 if ( ! empty( $search_result_page_id ) ) {
71 if ( function_exists( 'pll_get_post' ) ) {
72 $translated_id = pll_get_post( $search_result_page_id );
73 if ( ! empty( $translated_id ) ) {
74 $search_result_page_id = $translated_id;
75 }
76 } elseif ( function_exists( 'icl_object_id' ) ) {
77 $translated_id = icl_object_id( $search_result_page_id, 'page', true );
78 if ( ! empty( $translated_id ) ) {
79 $search_result_page_id = $translated_id;
80 }
81 }
82 }
83
84 $search_result_page_url = !empty($search_result_page_id) ? get_the_permalink( $search_result_page_id ) : site_url( '/easy-hotel-search-result' );
85 $seach_form_fileds = isset($eshb_settings['search-form-fields']) && !empty($eshb_settings['search-form-fields']) ? $eshb_settings['search-form-fields'] : [];
86
87
88 $adult_capacity = isset($eshb_settings['adult-capacity']) && !empty($eshb_settings['adult-capacity']) ? $eshb_settings['adult-capacity'] : 1000;
89 $children_capacity = isset($eshb_settings['children-capacity']) && !empty($eshb_settings['children-capacity']) ? $eshb_settings['children-capacity'] : 1000;
90 $min_adult_quantity = isset($eshb_settings['min-adult-capacity']) && !empty($eshb_settings['min-adult-capacity']) ? $eshb_settings['min-adult-capacity'] : 1;
91 $min_children_quantity = isset($eshb_settings['min-children-capacity']) && !empty($eshb_settings['min-children-capacity']) ? $eshb_settings['min-children-capacity'] : 0;
92
93 $room_capacity = isset($eshb_settings['room-capacity']) && !empty($eshb_settings['room-capacity']) ? $eshb_settings['room-capacity'] : 1000;
94
95 // Translations
96 $string_check_availability = isset($eshb_settings['string_check_availability']) && !empty($eshb_settings['string_check_availability']) ? $eshb_settings['string_check_availability'] : 'Check Availability';
97 $string_check_in = isset($eshb_settings['string_check_in']) && !empty($eshb_settings['string_check_in']) ? $eshb_settings['string_check_in'] : 'Check In';
98 $string_check_out = isset($eshb_settings['string_check_out']) && !empty($eshb_settings['string_check_out']) ? $eshb_settings['string_check_out'] : 'Check Out';
99 $string_adult = isset($eshb_settings['string_adult']) && !empty($eshb_settings['string_adult']) ? $eshb_settings['string_adult'] : 'Adult';
100 $string_children = isset($eshb_settings['string_children']) && !empty($eshb_settings['string_children']) ? $eshb_settings['string_children'] : 'Children';
101 $string_room = isset($eshb_settings['string_room']) && !empty($eshb_settings['string_room']) ? $eshb_settings['string_room'] : 'Room';
102 $has_search_calendar_icon = isset($eshb_settings['search-form-calendar-icon']) && !empty($eshb_settings['search-form-calendar-icon']) ? true : false;
103
104 ?>
105 <div class="eshb-search style-one">
106 <form action="<?php echo esc_url($search_result_page_url); ?>" method="get" class="eshb-search-form <?php echo esc_attr($has_search_calendar_icon ? 'eshb-has-calendar-icon' : ''); ?>">
107 <?php ESHB_Helper::eshb_nonce_field('eshb_global_nonce_action', 'nonce', true); ?>
108 <div class="eshb-form-group dates-wrapper">
109 <div class="eshb-form-group">
110 <h6 class="field-label"><?php echo esc_html(eshb_get_translated_string($string_check_in));?></h6>
111 <div class="eshb-input-wrapper">
112 <input type="text" id="date-picker_start_date" class="search-date-picker form-control" name="start_date" value="<?php echo esc_attr( $start_date ) ?>">
113 <?php if($has_search_calendar_icon){ ?>
114 <i class="eshb-calendar-icon far fa-calendar-alt"></i>
115 <?php } ?>
116 </div>
117 </div>
118 <div class="eshb-form-group">
119 <h6 class="field-label"><?php echo esc_html(eshb_get_translated_string($string_check_out));?></h6>
120 <div class="eshb-input-wrapper">
121 <input type="text" id="date-picker_end_date" class="search-date-picker form-control" name="end_date" value="<?php echo esc_attr( $end_date ) ?>">
122 <?php if($has_search_calendar_icon){ ?>
123 <i class="eshb-calendar-icon far fa-calendar-alt"></i>
124 <?php } ?>
125 </div>
126 </div>
127 </div>
128 <?php
129 if(in_array('adults', $seach_form_fileds)){ ?>
130 <div class="eshb-form-group">
131 <h6 class="field-label"><?php echo esc_html(eshb_get_translated_string($string_adult));?></h6>
132 <div class="de-number">
133 <span class="d-minus"><?php echo esc_html('-')?></span>
134 <input class="form-control" type="text" value="<?php echo esc_attr( $min_adult_quantity ) ?>" name="adult_quantity" max="<?php echo esc_attr( $adult_capacity ) ?>" min="<?php echo esc_attr( $min_adult_quantity ) ?>">
135 <span class="d-plus"><?php echo esc_html('+')?></span>
136 </div>
137 </div>
138
139 <?php }
140
141 if(in_array('childrens', $seach_form_fileds)){ ?>
142 <div class="eshb-form-group">
143 <h6 class="field-label"><?php echo esc_html(eshb_get_translated_string($string_children));?></h6>
144 <div class="de-number">
145 <span class="d-minus"><?php echo esc_html('-')?></span>
146 <input class="form-control" type="text" value="<?php echo esc_attr( $min_children_quantity ) ?>" name="children_quantity" max="<?php echo esc_attr( $children_capacity ) ?>" min="<?php echo esc_attr( $min_children_quantity ) ?>">
147 <span class="d-plus"><?php echo esc_html('+')?></span>
148 </div>
149 </div>
150 <?php }
151
152 if(in_array('rooms', $seach_form_fileds)){ ?>
153 <div class="eshb-form-group">
154 <h6 class="field-label"><?php echo esc_html(eshb_get_translated_string($string_room));?></h6>
155 <div class="de-number">
156 <span class="d-minus"><?php echo esc_html('-')?></span>
157 <input class="form-control" type="text" value="0" name="room_quantity" max="<?php echo esc_attr( $room_capacity ) ?>">
158 <span class="d-plus"><?php echo esc_html('+')?></span>
159 </div>
160 </div>
161 <?php }
162 ?>
163 <div class="eshb-form-group submition-wrapper py-0">
164 <button class="eshb-form-submit-btn" href="#"><?php echo esc_html(eshb_get_translated_string($string_check_availability));?></button>
165 </div>
166 <p class="err-msg"></p>
167 </form>
168
169 </div>
170 <?php
171 }
172
173 public function getNextAllowedStartDate($allowedDays, $date) {
174 $givenDate = DateTime::createFromFormat('Y-m-d', $date);
175 $dayOfWeek = (int) $givenDate->format('w'); // 0 = Sunday, 1 = Monday, ..., 6 = Saturday
176
177
178 $daysOfWeek = [
179 "sunday" => 0, "monday" => 1, "tuesday" => 2, "wednesday" => 3,
180 "thursday" => 4, "friday" => 5, "saturday" => 6
181 ];
182
183 if (!isset($daysOfWeek[strtolower($allowedDays[0])])) {
184 return false;
185 }
186
187 $targetDay = $daysOfWeek[strtolower($allowedDays[0])];
188
189 if ($dayOfWeek !== $targetDay) {
190 $daysToAdd = ($targetDay - $dayOfWeek + 7) % 7 ?: 7;
191 $givenDate->modify("+$daysToAdd days");
192 }
193
194 return $givenDate->format('Y-m-d');
195 }
196
197 public function eshb_get_booking_form_html($accomodation_id = null, $style = 'style-one', $form_attr = array()){
198
199 $form_attr_html = '';
200 if ( is_array( $form_attr ) ) {
201 foreach ( $form_attr as $attr_key => $attr_value ) {
202 $form_attr_html .= ' ' . esc_attr( $attr_key ) . '="' . esc_attr( $attr_value ) . '"';
203 }
204 }
205
206 if(is_singular( 'eshb_accomodation' ) && ($accomodation_id == null || empty($accomodation_id))){
207 $accomodation_id = get_the_ID();
208 }
209
210 if($accomodation_id == null || empty($accomodation_id)){
211 return 'invalid accomodation';
212 }
213
214 $eshb_settings = get_option( 'eshb_settings' );
215 $booking_type = isset($eshb_settings['booking-type']) && !empty($eshb_settings['booking-type']) ? $eshb_settings['booking-type'] : 'woocommerce';
216 $booking_form_type = isset($eshb_settings['booking-form-type']) && !empty($eshb_settings['booking-form-type']) ? $eshb_settings['booking-form-type'] : 'default';
217
218 if($booking_type != 'booking_request'){
219 $booking_form_type = 'default';
220 }
221
222 global $woocommerce;
223
224 $style_class = $style;
225
226 $hotel_core = new ESHB_Core();
227
228 $currency_symbol = $hotel_core->get_eshb_currency_symbol();
229
230 $accomodation_metaboxes = get_post_meta($accomodation_id, 'eshb_accomodation_metaboxes', true);
231
232 $min_max_nights_settings = [
233 'required_min_nights' => 1,
234 'required_max_nights' => 999,
235 ];
236
237 $min_max_nights_settings = apply_filters('eshb_min_max_nights_settings_before_search', $min_max_nights_settings, $accomodation_id, $accomodation_metaboxes);
238 $required_min_nights = !empty($min_max_nights_settings['required_min_nights']) ? $min_max_nights_settings['required_min_nights'] : 1;
239 $required_max_nights = !empty($min_max_nights_settings['required_max_nights']) ? $min_max_nights_settings['required_max_nights'] : 999;
240
241 $calendar_start_date_buffer = !empty($eshb_min_max_settings['calendar_start_date_buffer']) ? $eshb_min_max_settings['calendar_start_date_buffer'] : 0;
242
243 $today_date = gmdate('Y-m-d');
244 $today_date = gmdate( 'Y-m-d', strtotime($today_date . ' +' . $calendar_start_date_buffer . ' day')); // Get today's date
245
246 // Create a DateTime object from today's date
247 $date = new DateTime($today_date);
248
249 // Add one day
250 $date->modify('+'.$required_min_nights.' day');
251
252 // Get the new date in 'Y-m-d' format
253 $tomorrow = $date->format('Y-m-d');
254 $room_visibility = in_array('rooms', $eshb_settings['booking-form-fields']) ? true : false;
255 $adult_capacity = !empty($accomodation_metaboxes['adult_capacity']) ? $accomodation_metaboxes['adult_capacity'] : 1;
256 $children_capacity = !empty($accomodation_metaboxes['children_capacity']) ? $accomodation_metaboxes['children_capacity'] : 0;
257 $min_adult_quantity = !empty($eshb_settings['booking-min-adult-capacity']) ? $eshb_settings['booking-min-adult-capacity'] : 1;
258 $min_children_quantity = !empty($eshb_settings['booking-min-children-capacity']) ? $eshb_settings['booking-min-children-capacity'] : 0;
259 $room_capacity = !empty($accomodation_metaboxes['total_rooms']) ? $accomodation_metaboxes['total_rooms'] : 1;
260
261
262 $is_single_day_plugin_active = get_option('eshb_single_day_activated');
263
264 $pricing_periodicity = false;
265 $single_day_price = apply_filters( 'eshb_single_day_price', 0, $accomodation_id );
266 if ($is_single_day_plugin_active && $single_day_price) {
267 $pricing_periodicity = !empty($accomodation_metaboxes['pricing_periodicity']) ? $accomodation_metaboxes['pricing_periodicity'] : false;
268 }
269
270
271 // Verify nonce for security
272 if (isset($_GET['nonce']) && wp_verify_nonce( sanitize_text_field(wp_unslash($_GET['nonce'])), ESHB_Helper::generate_secure_nonce_action('eshb_global_nonce_action'))) {
273 $start_date = isset( $_GET['start_date'] ) && !empty($_GET['start_date']) ? sanitize_text_field( wp_unslash($_GET['start_date'] )) : $today_date;
274 $end_date = isset( $_GET['end_date'] ) && !empty($_GET['end_date']) ? sanitize_text_field( wp_unslash($_GET['end_date'] )) : $tomorrow;
275 $adult_quantity = isset( $_GET['adult_quantity'] ) && !empty($_GET['adult_quantity']) ? sanitize_text_field( wp_unslash($_GET['adult_quantity'] )) : 1;
276 $children_quantity = isset( $_GET['children_quantity'] ) && !empty($_GET['children_quantity']) ? sanitize_text_field( wp_unslash($_GET['children_quantity'] )) : 0;
277 $adult_quantity = $adult_quantity > $adult_capacity ? $adult_capacity : $adult_quantity;
278 $children_quantity = $children_quantity > $children_capacity ? $children_capacity : $children_quantity;
279 $room_quantity = isset( $_GET['room_quantity'] ) && !empty($_GET['room_quantity']) ? sanitize_text_field( wp_unslash($_GET['room_quantity'] )) : 1;
280 $room_quantity = $room_quantity > $room_capacity ? $room_capacity : $room_quantity;
281
282 }else{
283 $start_date = $today_date;
284 $end_date = $tomorrow;
285 $adult_quantity = 1;
286 $children_quantity = 0;
287 $room_quantity = 1;
288 }
289
290 $adult_quantity = $adult_quantity > $adult_capacity ? $adult_capacity : $adult_quantity;
291 $children_quantity = $children_quantity > $children_capacity ? $children_capacity : $children_quantity;
292
293 $adult_quantity = $adult_quantity < $min_adult_quantity ? $min_adult_quantity : $adult_quantity;
294 $children_quantity = $children_quantity < $min_children_quantity ? $min_children_quantity : $children_quantity;
295
296 // set end to same as start date for single day hourly booking
297 if($pricing_periodicity == 'per_hour') {
298 $end_date = $start_date;
299 }
300
301 $start = new DateTime($start_date);
302 $end = new DateTime($end_date);
303 $interval = $start->diff($end);
304 $days_count = $interval->days;
305 $allowed_check_in_day = isset($accomodation_metaboxes['allowed_check_in_day']) && !empty($accomodation_metaboxes['allowed_check_in_day']) ? $accomodation_metaboxes['allowed_check_in_day'] : [];
306
307 if(!empty($allowed_check_in_day)){
308 // push the day to array if its string
309 if(is_string($allowed_check_in_day)){
310 $allowed_check_in_day = [$allowed_check_in_day];
311 }
312
313 $allowed_check_in_day = array_map('strtolower', $allowed_check_in_day);
314
315 // Add 1 day to get the next allowed end date
316 $next_allowed_start_date = $this->getNextAllowedStartDate($allowed_check_in_day, $start_date);
317
318 if(!empty($next_allowed_start_date) && !empty($next_allowed_end_date)){
319 $start_date = $next_allowed_start_date;
320 //$end_date = $next_allowed_end_date;
321 }
322 }
323
324
325 $currency_symbol = $hotel_core->get_eshb_currency_symbol();
326 $per_night_price_html = $hotel_core->get_eshb_price_html('', '', $accomodation_id, true, false, true, true);
327 $price_html = $hotel_core->get_eshb_price_html($start_date, $end_date, $accomodation_id, true, false, true, true, 'regular');
328 $price = $hotel_core->get_eshb_price_html($start_date, $end_date, $accomodation_id, false, true, true, false);
329 $price = !empty($price) ? $price : 0;
330
331 // discounted pricing
332 $discountedPrice = $hotel_core->get_eshb_price_html($start_date, $end_date, $accomodation_id, false, true, true, true);
333 $discountedPrice = !empty($discountedPrice) ? $discountedPrice : 0;
334
335
336
337
338
339 $booking_form_fileds = $eshb_settings['booking-form-fields'];
340 $external_booking_link = isset($eshb_settings['external-booking-link']) && !empty($eshb_settings['external-booking-link']) ? $eshb_settings['external-booking-link'] : false;
341
342 // Translations
343 $string_reserve = isset($eshb_settings['string_reserve']) && !empty($eshb_settings['string_reserve']) ? $eshb_settings['string_reserve'] : 'Reserve';
344 $string_from = isset($eshb_settings['string_from']) && !empty($eshb_settings['string_from']) ? $eshb_settings['string_from'] : 'From';
345 $string_night = isset($eshb_settings['string_night']) && !empty($eshb_settings['string_night']) ? $eshb_settings['string_night'] : 'night';
346 $string_hour = isset($eshb_settings['string_hour']) && !empty($eshb_settings['string_hour']) ? $eshb_settings['string_hour'] : 'hour';
347 $string_check_in = isset($eshb_settings['string_check_in']) && !empty($eshb_settings['string_check_in']) ? $eshb_settings['string_check_in'] : 'Check In';
348 $string_check_out = isset($eshb_settings['string_check_out']) && !empty($eshb_settings['string_check_out']) ? $eshb_settings['string_check_out'] : 'Check Out';
349 $string_adult = isset($eshb_settings['string_adult']) && !empty($eshb_settings['string_adult']) ? $eshb_settings['string_adult'] : 'Adult';
350 $string_children = isset($eshb_settings['string_children']) && !empty($eshb_settings['string_children']) ? $eshb_settings['string_children'] : 'Children';
351 $string_rooms = isset($eshb_settings['string_rooms']) && !empty($eshb_settings['string_rooms']) ? $eshb_settings['string_rooms'] : 'Rooms';
352 $string_available_rooms = isset($eshb_settings['available_rooms']) && !empty($eshb_settings['available_rooms']) ? $eshb_settings['available_rooms'] : 'Available Rooms:';
353 $string_extra_bed = isset($eshb_settings['string_extra_bed']) && !empty($eshb_settings['string_extra_bed']) ? $eshb_settings['string_extra_bed'] : 'Extra Bed';
354 $string_extra_services = isset($eshb_settings['string_extra_services']) && !empty($eshb_settings['string_extra_services']) ? $eshb_settings['string_extra_services'] : 'Extra Services';
355 $string_total_cost = isset($eshb_settings['string_total_cost']) && !empty($eshb_settings['string_total_cost']) ? $eshb_settings['string_total_cost'] : 'Total Cost';
356 $string_disocunted_price = isset($eshb_settings['string_disocunted_price']) && !empty($eshb_settings['string_disocunted_price']) ? $eshb_settings['string_disocunted_price'] : 'Discounted Price';
357 $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';
358 $string_room = isset($eshb_settings['string_room']) && !empty($eshb_settings['string_room']) ? $eshb_settings['string_room'] : 'room';
359 $string_guest = isset($eshb_settings['string_guest']) && !empty($eshb_settings['string_guest']) ? $eshb_settings['string_guest'] : 'guest';
360 $string_time_slots = isset($eshb_settings['string_time_slots']) && !empty($eshb_settings['string_time_slots']) ? $eshb_settings['string_time_slots'] : 'Available Time Slots';
361 $string_please_wait = isset($eshb_settings['string_please_wait']) && !empty($eshb_settings['string_please_wait']) ? $eshb_settings['string_please_wait'] : 'Please Wait';
362
363 $included_service_ids = !empty($accomodation_metaboxes['accomodation_services']) ? $accomodation_metaboxes['accomodation_services'] : [];
364 $total_rooms = !empty($accomodation_metaboxes['total_rooms']) ? $accomodation_metaboxes['total_rooms'] : 0;
365 $eshb_bookings = new ESHB_Booking();
366 $available_rooms = $eshb_bookings->get_available_room_count_by_date_range($accomodation_id, $start->format('Y-m-d'), $end->format('Y-m-d'));
367 $available_rooms = $available_rooms < 0 ? 0 : $available_rooms;
368 $available_times = ESHB_Helper::get_available_times_by_date($accomodation_id, $start->format('Y-m-d'));
369 $price_html = $available_rooms < 1 ? $hotel_core->eshb_price(0) : $price_html;
370 $defaultExtraServicePrice = 0;
371
372 $has_calendar_icon = isset($eshb_settings['booking-form-calendar-icon']) && !empty($eshb_settings['booking-form-calendar-icon']) ? true : false;
373
374 $checked_services = [];
375 foreach($included_service_ids as $service_id){
376 $service_metaboxes = get_post_meta($service_id, 'eshb_service_metaboxes', true);
377 $is_checked = isset($service_metaboxes['is_checked']) && !empty($service_metaboxes['is_checked']) ? true : false;
378 if($is_checked){
379 $checked_services[] = $service_id;
380 }
381 }
382
383 $pricing = $eshb_bookings->calculate_booking_pricing(
384 $accomodation_id,
385 $start_date,
386 $end_date,
387 $room_quantity,
388 0,
389 $adult_quantity,
390 $children_quantity,
391 $checked_services,
392 true,
393 '',
394 ''
395 );
396
397 $price_html = $pricing['totalPriceHtml'];
398 $regular_total_price_html = $pricing['regularTotalPriceHtml'];
399
400 ?>
401 <div class="eshb-booking">
402 <div action="<?php echo esc_url(home_url('easy-hotel-search-result')); ?>" method="get"<?php echo $form_attr_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attributes are escaped per key/value above. ?> class="eshb-booking-form <?php echo esc_attr($style_class); ?> <?php echo esc_attr($has_calendar_icon ? 'eshb-has-calendar-icon' : ''); ?>" data-booking-form-type="<?php echo esc_attr($booking_form_type); ?>" data-pricing-periodicity="<?php echo esc_attr( $pricing_periodicity )?>">
403
404 <div class="eshb-form-loader">
405 <span class="eshb-form-loader__text"><?php echo esc_html( eshb_get_translated_string( $string_please_wait ) ); ?></span>
406 </div>
407
408 <div class="hidden-fields">
409 <input type="hidden" name="subtotal_price" id="eshb-subtotal-price" value="<?php echo esc_html($price);?>">
410 <input type="hidden" name="subtotal_price" id="eshb-discounted-subtotal-price" value="<?php echo esc_html($discountedPrice);?>">
411 <input type="hidden" name="default_extra_service_price" id="eshb-default-extra-service-price" value="<?php echo esc_html($defaultExtraServicePrice);?>">
412 <input type="hidden" name="accomodation_id" value="<?php echo esc_attr( $accomodation_id ); ?>">
413 <input type="hidden" name="accomodation_title" value="<?php echo esc_attr( get_the_title( $accomodation_id ) ); ?>">
414 <input type="hidden" name="currency_symbol" value="<?php echo esc_attr( $currency_symbol ); ?>">
415 </div>
416
417 <div class="eshb-form-group form-title-wrapper">
418 <h3 class="form-title"><?php echo esc_html( eshb_get_translated_string($string_reserve) );?></h3>
419 <?php if( $price > 0 ):?>
420 <span class="pricing"><?php echo esc_html(eshb_get_translated_string($string_from));?>
421 <h4 class="base-price"><?php echo wp_kses_post($per_night_price_html);?> / </h4>
422 <?php
423 if($pricing_periodicity && $pricing_periodicity == 'per_hour'){
424 echo esc_html( eshb_get_translated_string($string_hour) );
425 }else{
426 echo esc_html( eshb_get_translated_string($string_night) );
427 }
428 ?>
429 </span>
430 <?php endif; ?>
431 </div>
432 <div class="eshb-form-groups date-pickers-wrapper">
433 <div class="eshb-form-group start-date-pickers-wrapper">
434 <h6 class="field-label">
435 <?php
436 if($pricing_periodicity) { ?>
437 <?php echo esc_html( eshb_get_translated_string($string_check_in)) .'/'. esc_html( eshb_get_translated_string($string_check_out) );?>
438 <?php }else{ ?>
439 <?php echo esc_html( eshb_get_translated_string($string_check_in) );?>
440 <?php }
441 ?>
442 </h6>
443 <div class="eshb-input-wrapper">
444 <input type="text" id="booking-date-picker_start_date" class="booking-date-picker form-control" name="start_date" value="<?php echo esc_attr( $start_date ) ?>" accomodation_id="<?php echo esc_attr( $accomodation_id )?>">
445 <?php if($has_calendar_icon){ ?>
446 <i class="eshb-calendar-icon far fa-calendar-alt"></i>
447 <?php } ?>
448 </div>
449 </div>
450 <div class="eshb-form-group end-date-pickers-wrapper">
451 <h6 class="field-label"><?php echo esc_html( eshb_get_translated_string($string_check_out) );?></h6>
452 <div class="eshb-input-wrapper">
453 <input type="text" id="booking-date-picker_end_date" class="booking-date-picker form-control" name="end_date" value="<?php echo esc_attr( $end_date ) ?>" accomodation_id="<?php echo esc_attr( $accomodation_id )?>">
454 <?php if($has_calendar_icon){ ?>
455 <i class="eshb-calendar-icon far fa-calendar-alt"></i>
456 <?php } ?>
457 </div>
458 </div>
459
460 </div>
461 <p class="date-err-msg err-msg"></p>
462
463 <?php
464 $available_slots = !empty($available_times['available_slots']) ? $available_times['available_slots'] : [];
465 if($pricing_periodicity && $pricing_periodicity == 'per_hour' && count($available_times) > 0){ ?>
466 <div class="eshb-form-groups time-slots-wrapper <?php echo count($available_slots) > 0 ? 'has-time-slots' : ''?>">
467 <div class="eshb-form-group">
468 <h6 class="field-label"><?php echo esc_html( eshb_get_translated_string($string_time_slots) );?></h6>
469 <p class="empty-slot-msg err-msg"><?php echo esc_html__( 'All slots are Booked!', 'easy-hotel' ); ?></p>
470 <div class="time-slots">
471 <?php
472
473 if(count($available_slots) > 0){
474 foreach ($available_slots as $key => $slot) {
475
476 $max_start = gmdate("H:i", strtotime($slot[1] . " -1 hour"));
477 $min_end = gmdate("H:i", strtotime($slot[0] . " +1 hour"));
478
479 ?>
480 <div class="eshb-form-groups eshb-time-slot selected">
481 <input type="radio" name="time-slot" checked="" class="time-slot">
482 <div class="eshb-styled-checkbox"></div>
483 <div class="eshb-times">
484 <div class="eshb-time-wrapper">
485 <input type="time" id="booking-time-picker_start_time" class="booking-time-picker form-control" name="start_time" value="<?php echo esc_attr( $slot[0] )?>" min="<?php echo esc_attr( $slot[0] )?>" max="<?php echo esc_attr( $max_start )?>" step="1800">
486 </div>
487 -
488 <div class="eshb-time-wrapper">
489 <input type="time" id="booking-time-picker_end_time" class="booking-time-picker form-control" name="end_time" value="<?php echo esc_attr( $slot[1] )?>" min="<?php echo esc_attr( $min_end )?>" max="<?php echo esc_attr( $slot[1] )?>" step="1800">
490 </div>
491 </div>
492 </div>
493 <?php
494 }
495 }
496
497 ?>
498 </div>
499 </div>
500 <p class="time-err-msg err-msg"></p>
501 </div>
502 <?php } ?>
503
504 <div class="eshb-form-groups">
505 <?php
506 if(is_array($booking_form_fileds) && in_array('adults', $booking_form_fileds)){ ?>
507 <div class="eshb-form-group">
508 <h6 class="field-label"><?php echo esc_html( eshb_get_translated_string($string_adult) );?></h6>
509 <div class="de-number">
510 <span class="d-minus"><?php echo esc_html('-')?></span>
511 <input type="text" value="<?php echo esc_attr( $adult_quantity ); ?>" name="adult_quantity">
512 <span class="d-plus"><?php echo esc_html('+')?></span>
513 </div>
514 <p class="err-msg"></p>
515 </div>
516 <?php }
517
518 if(is_array($booking_form_fileds) && in_array('childrens', $booking_form_fileds)){ ?>
519 <div class="eshb-form-group">
520 <h6 class="field-label"><?php echo esc_html( eshb_get_translated_string($string_children) );?></h6>
521 <div class="de-number">
522 <span class="d-minus"><?php echo esc_html('-')?></span>
523 <input type="text" value="<?php echo esc_attr( $children_quantity ); ?>" name="children_quantity">
524 <span class="d-plus"><?php echo esc_html('+')?></span>
525 </div>
526 <p class="err-msg"></p>
527 </div>
528 <?php }
529 if(is_array($booking_form_fileds) && in_array('rooms', $booking_form_fileds)){
530
531 ?>
532 <div class="eshb-form-group">
533 <h6 class="field-label"><?php echo esc_html( eshb_get_translated_string($string_rooms) );?></h6>
534 <div class="de-number">
535 <span class="d-minus"><?php echo esc_html('-')?></span>
536 <input type="text" value="<?php echo $available_rooms > 0 ? 1 : 0 ?>" name="room_quantity">
537 <span class="d-plus" max="5"><?php echo esc_html('+')?></span>
538 </div>
539 <p class="capacity-status room-capacity-status"><?php echo esc_html( eshb_get_translated_string($string_available_rooms) ) . ' '; ?><span class="room-capacity-number"><?php echo esc_html( abs($available_rooms) ); ?></span></p>
540 <p class="err-msg"></p>
541
542 </div>
543 <?php }
544 if(is_array($booking_form_fileds) && in_array('extra_beds', $booking_form_fileds)){ ?>
545 <div class="eshb-form-group">
546 <h6 class="field-label"><?php echo esc_html( eshb_get_translated_string($string_extra_bed) );?></h6>
547 <div class="de-number">
548 <span class="d-minus"><?php echo esc_html('-')?></span>
549 <input type="text" value="0" name="extra_bed_quantity">
550 <span class="d-plus" max="5"><?php echo esc_html('+')?></span>
551 </div>
552 <p class="err-msg"></p>
553 </div>
554 <?php } ?>
555
556 </div>
557 <?php
558 if(is_array($included_service_ids) && count($included_service_ids) > 0 && $eshb_settings['extra-services-switcher'] == true){ ?>
559 <div class="eshb-form-group extra-services-wrapper">
560 <h3 class="field-label"><?php echo esc_html( eshb_get_translated_string($string_extra_services) );?></h3>
561 <ul class="service-list">
562 <?php
563
564 if(is_array($included_service_ids) && count($included_service_ids) > 0){
565
566 $total_services_price = 0;
567
568 foreach ($included_service_ids as $key => $service_id) {
569 $service = get_post($service_id);
570 if(!$service){
571 continue;
572 }
573 $service_name = get_the_title( $service_id );
574 $service_metaboxes = get_post_meta($service_id, 'eshb_service_metaboxes', true);
575 $service_periodicity = $service_metaboxes['service_periodicity'];
576 $service_charge_type = $service_metaboxes['service_charge_type'];
577
578 $service_price = $service_metaboxes['service_price'];
579 $service_price = apply_filters('eshb_service_price', $service_price);
580 $service_charge_type = str_replace('_', ' ', $service_metaboxes['service_charge_type']);
581
582 if(!empty($service_price)){
583 $total_services_price+=$service_price;
584 }
585
586 $is_checked = $service_metaboxes['is_checked'] ?? false;
587 $is_mandatory = $service_metaboxes['is_mandatory'] ?? false;
588
589 ?>
590 <li class="service-item">
591 <label for="eshb-service-message-<?php echo esc_attr( $service_id )?>" class="label-checkbox">
592 <input id="eshb-service-message-<?php echo esc_attr( $service_id )?>" type="checkbox" name="extra_services[]" value="<?php echo esc_attr($service_price) ?>" price="<?php echo esc_attr($service_price) ?>" service_id="<?php echo esc_attr( $service_id )?>" charge_type="<?php echo esc_attr( $service_charge_type ) ?>" periodicity="<?php echo esc_attr( $service_periodicity ) ?>" is_mandatory="<?php echo esc_attr( $is_mandatory ) ?>" title="<?php echo esc_attr($service_name) ?>" <?php checked( $is_checked ); ?>>
593 <div class="eshb-styled-checkbox"></div>
594 <span class="service-name"><?php echo esc_html($service_name, 'easy-hotel'); ?></span>
595 </label>
596 <div class="price-quantity">
597 <span class="price">
598 <?php
599
600
601 if($service_charge_type == 'room'){
602 $string_service_charge_type_translated = $string_room;
603 }else if($service_charge_type == 'guest'){
604 $string_service_charge_type_translated = $string_guest;
605 }else{
606 $string_service_charge_type_translated = $service_charge_type;
607 }
608
609 if ( ! empty( $service_price ) ) {
610 if ( ! $room_visibility && $service_charge_type === 'room' ) {
611 echo esc_html( $currency_symbol . $service_price );
612 } else {
613 echo esc_html( $currency_symbol . $service_price . ' / ' . eshb_get_translated_string( $string_service_charge_type_translated ) );
614 }
615 } else {
616 echo esc_html__( 'Free', 'easy-hotel' );
617 }
618
619
620 ?>
621 </span>
622 <?php
623 if( $service_charge_type != 'room'){
624 ?>
625 <div class="service-quantity-selector" id="service-quantity-selector">
626 <div class="de-number">
627 <span class="d-minus"><?php echo esc_html('-')?></span>
628 <span class="quantity-wrapper">
629 <input type="text" value="1" name="service-quantity" price="<?php echo esc_attr($service_price) ?>" charge_type="<?php echo esc_attr( $service_charge_type ) ?>" periodicity="<?php echo esc_attr( $service_periodicity ) ?>">
630 <span class="dropdown-arrow dashicons dashicons-arrow-down"></span>
631 </span>
632 <span class="d-plus"><?php echo esc_html('+')?></span>
633 </div>
634 </div>
635 <?php
636 }
637 ?>
638
639 </div>
640 </li>
641 <?php
642 }
643 }
644
645 ?>
646
647 </ul>
648 </div>
649 <?php }
650 ?>
651
652 <div class="eshb-form-group cost-calculator-wrapper">
653 <h3 class="field-label total-cost-label eshb-booking-total-pricing">
654 <?php echo esc_html(eshb_get_translated_string($string_total_cost));?>
655 <div class="eshb-booking-value" id="eshb-booking-total-price" currency_symbol="<?php echo esc_html( $currency_symbol ) ?>" subtotal_price=""><?php echo wp_kses_post($price_html);?></div>
656 </h3>
657 <h3 class="field-label total-cost-label eshb-booking-total-discounted-pricing">
658 <?php echo esc_html(eshb_get_translated_string($string_disocunted_price));?>
659 <div class="eshb-booking-value" id="eshb-booking-discounted-price" currency_symbol="<?php echo esc_html( $currency_symbol ) ?>" subtotal_price=""><?php echo wp_kses_post($price_html);?></div>
660 </h3>
661 </div>
662
663 <?php
664 if($booking_type == 'booking_request'){
665
666 if($booking_form_type == 'cf7' || $booking_form_type == 'fluentform'){
667 echo do_shortcode($eshb_settings['booking-form-shortcode']);
668 }else{
669 ?>
670 <div class="eshb-form-group eshb-booking-form-customer-details">
671 <h3 class="field-label"><?php echo esc_html__( 'Enter Your Detais', 'easy-hotel' ); ?></h3>
672 <div class="eshb-booking-form-customer-details-col">
673 <div class="eshb-form-group">
674 <input type="text" class="form-control" name="customer_name" placeholder="<?php echo esc_html__( 'Your name', 'easy-hotel' ); ?>">
675 <input type="email" class="form-control" name="customer_email" placeholder="<?php echo esc_html__( 'Your email', 'easy-hotel' ); ?>">
676 <input type="tel" class="form-control" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" name="customer_phone" placeholder="<?php echo esc_html__( 'Your phone', 'easy-hotel' ); ?>">
677 </div>
678 <div class="eshb-form-group">
679 <textarea name="customer_message" placeholder="Your message" class="form-control" style="height:100%"></textarea>
680 </div>
681 </div>
682 </div>
683 <?php
684 }
685
686
687 }
688
689 if($eshb_settings['booking-btn-switcher'] == true && $booking_form_type == 'default'){ ?>
690 <div class="eshb-form-group submition-wrapper">
691 <?php
692 if($booking_type == 'woocommerce'){ ?>
693 <button class="eshb-form-submit-btn" accomodation_id="<?php echo esc_attr($accomodation_id); ?>" booking_type="<?php echo esc_attr($booking_type); ?>"><?php echo esc_html( eshb_get_translated_string($string_book_your_stay) );?></button>
694 <?php }else if($booking_type == 'surecart'){ ?>
695 <button class="eshb-form-submit-btn" accomodation_id="<?php echo esc_attr($accomodation_id); ?>" booking_type="<?php echo esc_attr($booking_type); ?>"> <?php echo esc_html( eshb_get_translated_string($string_book_your_stay) );?> </button>
696 <?php }else if($booking_type == 'native_checkout'){ ?>
697 <button class="eshb-form-submit-btn" accomodation_id="<?php echo esc_attr($accomodation_id); ?>" booking_type="<?php echo esc_attr($booking_type); ?>"><?php echo esc_html( eshb_get_translated_string($string_book_your_stay) );?></button>
698 <?php }else if($booking_type == 'booking_request'){ ?>
699 <button class="eshb-form-submit-btn" accomodation_id="<?php echo esc_attr($accomodation_id); ?>" booking_type="<?php echo esc_attr($booking_type); ?>"><?php echo esc_html( eshb_get_translated_string($string_book_your_stay) );?></button>
700 <?php }else{ ?>
701 <a class="eshb-form-submit-btn" href="<?php echo esc_url( $external_booking_link ); ?>" target="_blank" accomodation_id="<?php echo esc_attr(get_the_ID()); ?>" booking_type="<?php echo esc_attr($booking_type); ?>"> <?php echo esc_html( eshb_get_translated_string($string_book_your_stay) );?> </a>
702 <?php }
703
704 ?>
705 </div>
706 <?php } ?>
707
708 <p class="eshb-form-err">
709 <span class="status status-success"><span class="status-icon"><img src="<?php echo esc_url( ESHB_PL_URL . 'public/assets/img/checked.png' ); ?>" alt=""></span><span class="status-msg"></span></span>
710 <span class="status status-failed"><span class="status-icon"><img src="<?php echo esc_url( ESHB_PL_URL . 'public/assets/img/warning.png' ); ?>" alt=""></span><span class="status-msg"></span></span>
711 </p>
712
713 </div>
714 </div>
715 <?php
716 }
717
718 public function eshb_get_pagination($query = null){
719 // Use the global $wp_query if no custom query is provided
720 if ( !$query ) {
721 global $wp_query;
722 $query = $wp_query;
723 }
724
725 // Check if there are enough posts to paginate
726 if ( $query->max_num_pages <= 1 ) {
727 return;
728 }
729
730 $big = 999999999; // Need an unlikely integer
731
732 // Generate pagination links
733 $pages = paginate_links( array(
734 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
735 'format' => '?paged=%#%',
736 'current' => max( 1, get_query_var('paged') ),
737 'total' => $query->max_num_pages,
738 'prev_text' => __('&laquo; Previous', 'easy-hotel'),
739 'next_text' => __('Next &raquo;', 'easy-hotel'),
740 'type' => 'array', // Output as array to customize
741 ) );
742
743 if ( is_array( $pages ) ) {
744 echo '<nav class="eshb-pagination"><ul class="pagination-list">';
745 foreach ( $pages as $page ) {
746 echo '<li>' . wp_kses_post($page) . '</li>';
747 }
748 echo '</ul></nav>';
749 }
750 }
751
752 public function eshb_get_availability_calendar_html($accomodation_id = null, $style = 'style-one', $show_title = true){
753
754 $eshb_settings = get_option('eshb_settings', []);
755
756 $availability_calendar_title = isset($eshb_settings['string_availability_calendar']) && !empty($eshb_settings['string_availability_calendar']) ? $eshb_settings['string_availability_calendar'] : __('Availability Calendar', 'easy-hotel');
757
758
759 global $woocommerce;
760
761 $style_class = $style;
762
763 if( $accomodation_id == null || empty($accomodation_id)){
764 global $post;
765 $accomodation_id = $post->ID;
766 }
767
768 $today_date = gmdate('Y-m-d'); // Get today's date
769
770 $min_max_settings = [
771 'calendar_start_date_buffer' => 0,
772 ];
773 $eshb_min_max_settings = apply_filters( 'eshb_min_max_global_settings_in_searach', $min_max_settings);
774 $calendar_start_date_buffer = !empty($eshb_min_max_settings['calendar_start_date_buffer']) ? $eshb_min_max_settings['calendar_start_date_buffer'] : 0;
775
776
777 $start_date = $today_date;
778 // Verify nonce for security
779 if (isset($_GET['nonce']) && wp_verify_nonce( sanitize_text_field(wp_unslash($_GET['nonce'])), 'eshb_nonce_action')) {
780 $start_date = isset( $_GET['start_date'] ) && !empty($_GET['start_date']) ? sanitize_text_field( wp_unslash($_GET['start_date'] )) : $today_date;
781 }
782
783 ?>
784 <div class="eshb-availability-calendars-area">
785 <?php if($show_title){ ?>
786 <h3 class="calendar-title"><?php echo esc_html( eshb_get_translated_string($availability_calendar_title) );?></h3>
787 <?php } ?>
788 <div class="eshb-availability-calendars">
789 <input type="hidden" id="booking-date-picker_start_date" class="booking-date-picker form-control" name="available_date_picker" value="<?php echo esc_attr( $start_date ) ?>" accomodation_id="<?php echo esc_attr( $accomodation_id )?>">
790 </div>
791 <?php do_action( 'eshb_before_availability_calendar', $accomodation_id ); ?>
792 <p class="eshb-availability-calendars-err eshb-calendar-msg"></p>
793 <?php
794 if(!empty($calendar_start_date_buffer)) {
795 ?>
796 <p class="eshb-availability-calendars-notice eshb-calendar-msg"><?php echo esc_html__( 'Some previous dates are not allowed for booking today. We set buffer for today + ', 'easy-hotel' ) . esc_html($calendar_start_date_buffer) ?></p>
797 <?php
798 }
799 ?>
800
801 </div>
802 <?php
803 }
804
805 // Limit Excerpt Length by number of Words
806 public function eshb_custom_excerpt( $limit, $post_id = null ) {
807
808 if($post_id == null || empty($post_id)) $post_id = get_the_ID();
809
810 $excerpt = explode(' ', get_the_excerpt($post_id), $limit);
811 if (count($excerpt)>=$limit) {
812 array_pop($excerpt);
813 $excerpt = implode(" ",$excerpt).'...';
814 } else {
815 $excerpt = implode(" ",$excerpt);
816 }
817 $excerpt = preg_replace('`[[^]]*]`','',$excerpt);
818 return $excerpt;
819 }
820
821 public function eshb_get_gallery_html($accomodation_id = null, $unique_id = '', $thumbnail_size ='full', $sliderDots = 'false', $sliderNav = 'true'){
822
823 $eshb_accomodation_metaboxes_side = get_post_meta($accomodation_id, 'eshb_accomodation_metaboxes_side', true);
824 $accomodation_hero_type = !empty($eshb_accomodation_metaboxes_side['accomodation_hero_type']) ? $eshb_accomodation_metaboxes_side['accomodation_hero_type'] : 'gallery';
825 $accomodation_gallery = !empty($eshb_accomodation_metaboxes_side['accomodation_gallery']) ? $eshb_accomodation_metaboxes_side['accomodation_gallery'] : '';
826 $accomodation_video = !empty($eshb_accomodation_metaboxes_side['accomodation_video']) ? $eshb_accomodation_metaboxes_side['accomodation_video'] : '';
827 $accomodation_video_source = !empty($eshb_accomodation_metaboxes_side['accomodation_video_source']) ? $eshb_accomodation_metaboxes_side['accomodation_video_source'] : '';
828 $accomodation_gallery_ids = explode( ',', $accomodation_gallery );
829 $accomodation_gallery_slides_per_view = !empty($eshb_accomodation_metaboxes_side['slides_per_view']) ? $eshb_accomodation_metaboxes_side['slides_per_view'] : '2.1';
830 $accomodation_video_height = !empty($eshb_accomodation_metaboxes_side['accomodation_video_height']) ? $eshb_accomodation_metaboxes_side['accomodation_video_height'] : 0;
831
832
833 if($accomodation_hero_type != 'video'){
834 ?>
835 <!-- Slider main container -->
836 <div class="swiper gallery-wrapper accomodation-gallery accomodation-gallery-<?php echo esc_attr($unique_id) ?> <?php echo count($accomodation_gallery_ids) > 1 ? 'has-accomodation-gallery has-accomodation-gallery-'.esc_attr($unique_id) : '' ?>" data-slides-per-view="<?php echo esc_attr($accomodation_gallery_slides_per_view); ?>">
837 <!-- Additional required wrapper -->
838 <div class="swiper-wrapper">
839 <!-- Slides -->
840 <?php
841 foreach ( $accomodation_gallery_ids as $gallery_item_id ) { ?>
842 <div class="swiper-slide">
843 <?php echo wp_get_attachment_image( $gallery_item_id, $thumbnail_size ); ?>
844 </div>
845
846 <?php }
847 ?>
848
849 </div>
850
851 <?php
852 if( count($accomodation_gallery_ids) > 1 && !empty($sliderDots == 'true' || $sliderNav == 'true') ) : ?>
853 <?php
854 if($sliderDots == 'true') : ?>
855 <div class="swiper-pagination eshb-text-center"></div>
856 <?php endif;
857
858 if($sliderNav == 'true') : ?>
859 <!-- If we need navigation buttons -->
860 <div class="swiper-button-prev"></div>
861 <div class="swiper-button-next"></div>
862 <?php endif; ?>
863
864 <?php endif; ?>
865
866 </div>
867
868 <?php
869 }else{
870 if(!empty($accomodation_video) && !empty($accomodation_video_source)){
871
872
873 if($accomodation_video_source == 'external'){
874
875 // Extract the video ID from the YouTube URL
876
877 preg_match('/(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/', $accomodation_video, $matches);
878
879 // If a valid video ID is found, create the autoplay embed URL
880 if (isset($matches[1])) {
881 $video_id = $matches[1];
882 $autoplay_url = 'https://www.youtube.com/embed/' . $video_id . '?autoplay=1&mute=1&controls=0&modestbranding=1&rel=0';
883 }
884 ?>
885 <div class="accomodation-video eshb-external-video" style="<?php echo !empty($accomodation_video_height) ? 'height:' . esc_attr($accomodation_video_height) . 'px' : 'padding-bottom: 56.25%;'; ?>">
886 <?php
887 echo '<iframe width="auto" height="' . esc_attr($accomodation_video_height) . 'px" src="' . esc_url($autoplay_url) . '" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>';
888 ?>
889 </div>
890
891
892 <?php
893 }else if($accomodation_video_source == 'self_hosted'){
894 ?>
895 <div class="accomodation-video eshb-self-hosted-video" style="<?php echo !empty($accomodation_video_height) ? 'height:' . esc_attr($accomodation_video_height).'px' : 'height: auto'; ?>">
896 <video autoplay muted loop width="100%" <?php echo !empty($accomodation_video_height) ? 'height=' . esc_attr($accomodation_video_height) : 'height=auto'; ?>>
897 <source src="<?php echo esc_url($accomodation_video);?>" type="video/mp4">
898 <?php echo esc_html__( 'Your browser does not support the video tag.', 'easy-hotel' ); ?>
899 </video>
900 </div>
901 <?php
902 }
903
904 }
905
906
907 }
908 }
909
910 public function eshb_day_wise_pricing_table_html($accomodation_id = null, $show_title = false){
911
912 if( $accomodation_id == null || empty($accomodation_id)){
913 global $post;
914 $accomodation_id = $post->ID;
915 }
916
917 $hotel_core = new ESHB_Core();
918
919 $accomodation_metaboxes = get_post_meta($accomodation_id, 'eshb_accomodation_metaboxes', true);
920 $day_wise_price = isset($accomodation_metaboxes['day_wise_price']) && !empty($accomodation_metaboxes['day_wise_price'][0]) ? $accomodation_metaboxes['day_wise_price'][0] : [];
921
922
923 $day_wise_price = array_filter($day_wise_price, function($value) {
924 return !empty($value) && $value != 0;
925 });
926
927 if (empty($day_wise_price)) {
928 return; // return if all values are empty or 0
929 }
930
931 $default_price = $hotel_core->get_eshb_price('', '', $accomodation_id, false, true, false, true);
932 $all_days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
933 $currency_symbol = $hotel_core->get_eshb_currency_symbol();
934
935 ?>
936 <div class="eshb-day-wise-pricing-table-container">
937 <?php
938 if($show_title == true) : ?>
939 <h3 class="eshb-day-wise-pricing-table-title"><?php echo esc_html__( 'Day Wise Pricing', 'easy-hotel' ); ?></h3>
940 <?php endif; ?>
941 <div class="eshb-day-wise-pricing-table-wrapper table-responsive">
942 <table class="eshb-day-wise-pricing-table table table-striped">
943 <thead>
944 <tr>
945 <?php
946 foreach ($all_days as $day) {
947 ?>
948 <th><?php echo esc_html(ucfirst($day)); ?></th>
949 <?php
950 }
951 ?>
952 </tr>
953 </thead>
954 <tbody>
955 <tr>
956 <?php
957 foreach ($all_days as $day) {
958 $daily_price = isset($day_wise_price[$day]) && $day_wise_price[$day] !== '' ? $day_wise_price[$day] : $default_price;
959 ?>
960 <td><?php echo esc_html($currency_symbol . $daily_price); ?></td>
961 <?php
962 }
963 ?>
964 </tr>
965 </tbody>
966 </table>
967 </div>
968
969 </div>
970 <?php
971
972 }
973
974 public function eshb_get_eshb_check_in_out_times_html($show_title = false){
975 $eshb_settings = get_option('eshb_settings', []);
976 $check_in_time = isset($eshb_settings['check-in-time']) && !empty($eshb_settings['check-in-time']) ? $eshb_settings['check-in-time'] : '';
977 $check_out_time = isset($eshb_settings['check-out-time']) && !empty($eshb_settings['check-out-time']) ? $eshb_settings['check-out-time'] : '';
978
979 if(empty($check_in_time) && empty($check_out_time)){
980 return;
981 }
982 ?>
983 <div class="eshb-check-in-out-times-area">
984 <?php
985 if($show_title == true) : ?>
986 <h3 class="eshb-check-in-out-times-title"><?php echo esc_html__( 'Check In & Check Out Times', 'easy-hotel' ); ?></h3>
987 <?php endif; ?>
988
989 <div class="eshb-check-in-out-times">
990 <?php
991 if(!empty($check_in_time)){
992 $check_in_time = date_i18n( get_option( 'time_format' ), strtotime($check_in_time) );
993 ?>
994 <p class="eshb-check-in-time"><span class="eshb-check-in-label"><?php echo esc_html__( 'Check In Time:', 'easy-hotel' ); ?></span> <span class="eshb-check-in-time-value"><?php echo esc_html($check_in_time); ?></span></p>
995 <?php
996 }
997 if(!empty($check_out_time)){
998 $check_out_time = date_i18n( get_option( 'time_format' ), strtotime($check_out_time) );
999 ?>
1000 <p class="eshb-check-out-time"><span class="eshb-check-out-label"><?php echo esc_html__( 'Check Out Time:', 'easy-hotel' ); ?></span> <span class="eshb-check-out-time-value"><?php echo esc_html($check_out_time); ?></span></p>
1001 <?php
1002 }
1003 ?>
1004 </div>
1005 </div>
1006
1007 <?php
1008 }
1009 }
1010
1011
1012
1013