PluginProbe
Booking Calendar / 10.10
Booking Calendar v10.10
11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 10.11.3 All 202 releases
booking / core / lib / wpdev-booking-class.php

wpdev-booking-class.php in Booking Calendar 10.10, at core/lib/wpdev-booking-class.php

1,121 lines 53.5 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
4 class wpdev_booking {
5
6 public $popover_front_end_js_is_writed; //FixIn: Flex TimeLine 1.0 -- previos this was private and not public property
7
8 // <editor-fold defaultstate="collapsed" desc=" C O N S T R U C T O R & P r o p e r t i e s ">
9
10 var $wpdev_bk_personal;
11
12 function __construct() {
13
14 // In AJAX request it DO NOT RUNNING. Important note
15
16 $this->popover_front_end_js_is_writed = false;
17
18 if ( class_exists( 'wpdev_bk_personal' ) ) {
19 $this->wpdev_bk_personal = new wpdev_bk_personal();
20 } else {
21 $this->wpdev_bk_personal = false;
22 }
23
24
25 // User defined - hooks
26 add_action( 'wpdev_bk_add_calendar', array( &$this, 'add_calendar_action' ), 10, 2 );
27 add_action( 'wpdev_bk_add_form', array( &$this, 'add_booking_form_action' ), 10, 2 );
28 add_bk_action( 'wpdevbk_add_form', array( &$this, 'add_booking_form_action' ) );
29 add_filter( 'wpdev_bk_get_form', array( &$this, 'get_booking_form_action' ), 10, 2 );
30 add_bk_filter( 'wpdevbk_get_booking_form', array( &$this, 'get_booking_form_action' ) );
31 add_filter( 'wpdev_bk_get_showing_date_format', array( &$this, 'get_showing_date_format' ), 10, 1 );
32
33 // Get script for calendar activation
34 add_bk_filter( 'pre_get_calendar_html', array( &$this, 'pre_get_calendar_html' ) );
35
36 add_action( 'init', array( $this, 'wpbc_shortcodes_init' ), 9999 ); // <- priority to load it last
37 }
38 // </editor-fold>
39
40
41 /**
42 * S H O R T C O D E s Init
43 *
44 * @return void
45 */
46 function wpbc_shortcodes_init(){
47
48 add_shortcode( 'booking', array( &$this, 'booking_shortcode' ) );
49 add_shortcode( 'bookingcalendar', array( &$this, 'booking_calendar_only_shortcode' ) );
50 add_shortcode( 'bookingform', array( &$this, 'bookingform_shortcode' ) );
51 add_shortcode( 'bookingedit', array( &$this, 'bookingedit_shortcode' ) );
52 add_shortcode( 'bookingsearch', array( &$this, 'bookingsearch_shortcode' ) );
53 add_shortcode( 'bookingsearchresults', array( &$this, 'bookingsearchresults_shortcode' ) );
54 add_shortcode( 'bookingselect', array( &$this, 'bookingselect_shortcode' ) );
55 add_shortcode( 'bookingresource', array( &$this, 'bookingresource_shortcode' ) );
56 add_shortcode( 'bookingtimeline', array( &$this, 'bookingtimeline_shortcode' ) );
57 add_shortcode( 'bookingcustomerlisting', array( &$this, 'bookingcustomerlisting_shortcode' ) ); // FixIn: 8.1.3.5.
58
59 }
60
61
62 // <editor-fold defaultstate="collapsed" desc=" S U P P O R T F U N C T I O N S ">
63
64 function silent_deactivate_WPBC() {
65 deactivate_plugins( WPBC_PLUGIN_DIRNAME . '/' . WPBC_PLUGIN_FILENAME, true );
66 }
67
68
69 // Change date format
70 function get_showing_date_format( $mydate ) {
71 $date_format = get_bk_option( 'booking_date_format' );
72 if ( $date_format == '' ) {
73 $date_format = "d.m.Y";
74 }
75
76 $time_format = get_bk_option( 'booking_time_format' );
77 if ( $time_format !== false ) {
78 $time_format = ' ' . $time_format;
79 $my_time = gmdate( 'H:i:s', $mydate );
80 if ( $my_time == '00:00:00' ) {
81 $time_format = '';
82 }
83 } else {
84 $time_format = '';
85 }
86
87 // return gmdate($date_format . $time_format , $mydate);
88 return date_i18n( $date_format, $mydate ) . '<sup class="booking-table-time">' . date_i18n( $time_format, $mydate ) . '</sup>';
89 }
90
91 // </editor-fold>
92
93
94 // <editor-fold defaultstate="collapsed" desc=" B O O K I N G s A D M I N F U N C T I O N s ">
95
96 /**
97 * Generate booking CAPTCHA fields for booking form
98 *
99 * @param $bk_tp resource ID
100 *
101 * @return string|true
102 */
103 function createCapthaContent($bk_tp) {
104
105 $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url( 'admin.php?' ) ), '/' );
106
107 $server_request_uri = ( ( isset( $_SERVER['REQUEST_URI'] ) ) ? sanitize_text_field( $_SERVER['REQUEST_URI'] ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash */ /* FixIn: sanitize_unslash */
108
109 if ( ( get_bk_option( 'booking_is_use_captcha' ) !== 'On' )
110 || (
111 ( strpos( $server_request_uri, $admin_uri ) !== false )
112 && ( ! wpbc_is_settings_form_page() )
113 )
114 ) {
115 return '';
116 } else {
117
118 $html = wpbc_captcha__simple__generate_html_content( $bk_tp );
119
120 return $html;
121 }
122 }
123
124 // Get default Booking resource
125 function get_default_type() {
126
127 if ( $this->wpdev_bk_personal !== false ) {
128 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
129 if ( ( isset( $_GET['booking_type'] ) ) && ( $_GET['booking_type'] != '' ) ) {
130 $bk_type = sanitize_text_field( wp_unslash( $_GET['booking_type'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
131 } else {
132 $bk_type = $this->wpdev_bk_personal->get_default_booking_resource_id();
133 }
134 } else {
135 $bk_type = 1;
136 }
137
138 return $bk_type;
139 }
140
141 // </editor-fold>
142
143
144 // <editor-fold defaultstate="collapsed" desc=" C L I E N T S I D E & H O O K S ">
145
146
147 // Get HTML for the initilizing inline calendars
148 function pre_get_calendar_html( $resource_id=1, $cal_count=1, $bk_otions=array() ){
149 //SHORTCODE:
150 /*
151 * [booking type=56 form_type='standard' nummonths=4
152 * options='{calendar months_num_in_row=2 width=682px cell_height=48px}']
153 */
154
155 $bk_otions = wpbc_parse_calendar_options($bk_otions);
156 /* options:
157 [months_num_in_row] => 2
158 [width] => 341px define: width: 100%; max-width:341px;
159 [strong_width] => 341px define: width:341px;
160 [cell_height] => 48px
161 */
162 $width = $months_num_in_row = $cell_height = '';
163
164 if (!empty($bk_otions)){
165
166 if ( isset( $bk_otions['months_num_in_row'] ) ) {
167 $months_num_in_row = $bk_otions['months_num_in_row'];
168 }
169
170 if ( isset( $bk_otions['width'] ) ) {
171 $width = 'width:100%;max-width:' . $bk_otions['width'] . ';'; // FixIn: 9.3.1.5.
172 }
173 if ( isset( $bk_otions['strong_width'] ) ) {
174 $width .= 'width:' . $bk_otions['strong_width'] . ';'; // FixIn: 9.3.1.6.
175 }
176
177 if ( isset( $bk_otions['cell_height'] ) ) {
178 $cell_height = $bk_otions['cell_height'];
179 }
180 if ( isset( $bk_otions['strong_cell_height'] ) ) { // FixIn: 9.7.3.3.
181 $cell_height = $bk_otions['strong_cell_height'] . '!important;';
182 }
183 }
184 /* FixIn: 9.7.3.4 */
185
186 if ( ! empty( $cell_height ) ) {
187 // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
188 $style = '<style type="text/css" rel="stylesheet" >' . '.hasDatepick .datepick-inline .datepick-title-row th,' . '.hasDatepick .datepick-inline .datepick-days-cell{' . ' height: ' . $cell_height . '; ' . '}' . '</style>';
189 } else {
190 $style = '';
191 }
192
193 // FixIn: 8.2.1.27.
194 $booking_timeslot_day_bg_as_available = get_bk_option( 'booking_timeslot_day_bg_as_available' );
195
196 $booking_timeslot_day_bg_as_available = ( $booking_timeslot_day_bg_as_available === 'On' ) ? ' wpbc_timeslot_day_bg_as_available' : '';
197
198 //FixIn: 9.8.1
199 $is_custom_width_css = ( empty( $width ) ) ? ' wpbc_no_custom_width ' : '';
200
201 $calendar = $style.
202 '<div class="wpbc_cal_container bk_calendar_frame' . $is_custom_width_css . ' months_num_in_row_' . $months_num_in_row . ' cal_month_num_' . $cal_count . $booking_timeslot_day_bg_as_available . '" style="' . $width . '">' .
203 '<div id="calendar_booking' . $resource_id . '">' .
204 __('Calendar is loading...' ,'booking').
205 '</div>'.
206 '</div>'.
207 '';
208
209 $booking_is_show_powered_by_notice = get_bk_option( 'booking_is_show_powered_by_notice' );
210 if ( ( ! class_exists( 'wpdev_bk_personal' ) ) && ( $booking_is_show_powered_by_notice == 'On' ) ) {
211 $calendar .= '<div style="font-size:7px;text-align:left;margin:0 0 10px;text-shadow: none;">Powered by <a href="https://wpbookingcalendar.com" style="font-size:7px;" target="_blank" title="Booking Calendar plugin for WordPress">Booking Calendar</a></div>';
212 }
213
214 $calendar .= '<textarea id="date_booking' . $resource_id . '" name="date_booking' . $resource_id . '" autocomplete="off" style="display:none;"></textarea>'; // Calendar code
215
216 $calendar .= wpbc_get_calendar_legend(); // FixIn: 9.4.3.6.
217
218 $calendar_css_class_outer = 'wpbc_calendar_wraper';
219
220 // FixIn: 7.0.1.24.
221 $is_booking_change_over_days_triangles = get_bk_option( 'booking_change_over_days_triangles' );
222 if ( $is_booking_change_over_days_triangles !== 'Off' ) {
223 $calendar_css_class_outer .= ' wpbc_change_over_triangle';
224 }
225
226
227 // filenames, such as 'multidays.css'
228 $calendar_skin_name = basename( get_bk_option( 'booking_skin' ) );
229 if ( wpbc_is_calendar_skin_legacy( $calendar_skin_name ) ) {
230 $calendar_css_class_outer .= ' wpbc_calendar_skin_legacy'; //. wpbc_get_slug_format( get_bk_option( 'booking_skin' ) );
231 }
232
233 $calendar = '<div class="' . esc_attr( $calendar_css_class_outer ) . '">' . $calendar . '</div>';
234
235 return $calendar;
236 }
237
238
239
240 // Get booking form
241 function get_booking_form_action( $resource_id = 1, $my_boook_count = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $start_month_calendar = false, $bk_otions = array() ) {
242
243 $res = $this->add_booking_form_action($resource_id,$my_boook_count, 0, $my_booking_form , $my_selected_dates_without_calendar, $start_month_calendar, $bk_otions );
244 return $res;
245 }
246
247 //Show booking form from action call - wpdev_bk_add_form
248 function add_booking_form_action( $resource_id = 1, $cal_count = 1, $is_echo = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $start_month_calendar = false, $bk_otions = array() ) {
249
250 $additional_bk_types = array();
251 if ( strpos($resource_id,';') !== false ) {
252 $additional_bk_types = explode(';',$resource_id);
253 $resource_id = $additional_bk_types[0];
254 }
255
256 //--------------------------------------------------------------------------------------------------------------
257 // Check if booking resource exist
258 if ( $resource_id == '' ) {
259 $my_result = __( 'Booking resource type is not defined. This can be, when at the URL is wrong booking hash.', 'booking' );
260 if ( $is_echo ) {
261 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
262 echo $my_result;
263 } else {
264 return $my_result;
265 }
266
267 return;
268 }
269
270 $is_booking_resource_exist = apply_bk_filter('wpdev_is_booking_resource_exist',true, $resource_id, $is_echo );
271 if (! $is_booking_resource_exist) {
272 if ( $is_echo ) echo 'Booking resource does not exist.' . ' [ID=' . esc_attr( $resource_id ) . ']';
273 return 'Booking resource does not exist.' . ' [ID=' . esc_attr( $resource_id ) . ']';
274 }
275
276 //--------------------------------------------------------------------------------------------------------------
277 // Define $this->client_side_active_params_of_user to specific User,
278 // depends from belonging booking resource to specific User
279 make_bk_action('check_multiuser_params_for_client_side', $resource_id );
280
281 //--------------------------------------------------------------------------------------------------------------
282 // Get Booking ID and booking resource ID, if we EDIT booking
283 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
284 if ( isset( $_GET['booking_hash'] ) ) {
285
286 $get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
287
288 $my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $get_booking_hash );
289
290 $is_error = false; // FixIn: 9.1.3.2.
291 if ( $my_booking_id_type !== false ) {
292
293 list( $my_edited_bk_id, $my_boook_type ) = $my_booking_id_type;
294
295 if ( $my_boook_type == '' ) {
296 $is_error ='<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking');
297 }
298 } else {
299 $is_error = '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking');
300 }
301
302 if ( false !== $is_error ) {
303 if ( $is_echo ) {
304 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
305 echo $is_error;
306 }
307 return $is_error;
308 }
309
310 // Check situation when we have editing "child booking resource", so need to reupdate calendar and form to have it for parent resource.
311 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
312 if ( ( ! isset( $_GET['booking_pay'] ) ) && ( ! isset( $_GET['resource_no_update'] ) )
313 && ( function_exists( 'wpbc_is_this_child_resource' ) )
314 && ( wpbc_is_this_child_resource( $my_boook_type ) )
315 ){
316 $bk_parent_br_id = wpbc_get_parent_resource( $my_boook_type );
317 $resource_id = $bk_parent_br_id;
318 }
319 }
320
321 //--------------------------------------------------------------------------------------------------------------
322 // Get JS vars for Booked dates | Rates | Availability & define function for showing calendar
323
324 $start_script_code = wpbc__calendar__load( array(
325 'resource_id' => $resource_id,
326 'aggregate_resource_id_arr' => $additional_bk_types,
327 'selected_dates_without_calendar' => $my_selected_dates_without_calendar,
328 'calendar_number_of_months' => $cal_count,
329 'start_month_calendar' => $start_month_calendar,
330 'shortcode_options' => $bk_otions,
331 'custom_form' => ( isset( $_GET['booking_form'] ) ) ? wpbc_clean_text_value( $_GET['booking_form'] ) : $my_booking_form // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
332 ));
333
334
335 if ( $my_selected_dates_without_calendar !== '' ) { // FixIn: 9.3.1.1.
336 // Disable booked time slots, for predefined selected date in the booking form (it's shortcode for booking form, without the calendar)
337 $start_script_code .= '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7.
338 $start_script_code .= " bkDisableBookedTimeSlots( jQuery( '#date_booking{$resource_id}' ).val(), {$resource_id} ); ";
339 $start_script_code .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7.
340 }
341
342
343 //--------------------------------------------------------------------------------------------------------------
344 // Get booking form content
345 $my_result = ' ' . $this->get__client_side_booking_content($resource_id, $my_booking_form, $my_selected_dates_without_calendar, $cal_count, $bk_otions ) . ' ' . $start_script_code ;
346
347
348 $my_result = apply_filters('wpdev_booking_form', $my_result , $resource_id); // Add DIV structure, where to show payment form
349
350
351 make_bk_action('finish_check_multiuser_params_for_client_side', $resource_id );
352
353 if ( $is_echo ) {
354 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
355 echo $my_result;
356 } else {
357 return $my_result;
358 }
359 }
360
361
362 /**
363 * For [bookingcalendar ... ] shortcode Only!
364 *
365 * @param $resource_id
366 * @param $cal_count
367 * @param $is_echo
368 * @param $start_month_calendar
369 * @param $bk_otions
370 *
371 * @return string|void
372 */
373 function add_calendar_action( $resource_id = 1, $cal_count = 1, $is_echo = 1, $start_month_calendar = false, $bk_otions = array() ) {
374
375 $additional_bk_types = array();
376 if ( strpos($resource_id,';') !== false ) {
377 $additional_bk_types = explode(';',$resource_id);
378 $resource_id = $additional_bk_types[0];
379 }
380
381 make_bk_action('check_multiuser_params_for_client_side', $resource_id );
382
383 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
384 if (isset($_GET['booking_hash'])) {
385 $get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
386 $my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $get_booking_hash );
387 if ($my_booking_id_type != false)
388 if ($my_booking_id_type[1]=='') {
389 $my_result = '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking');
390 if ( $is_echo ) {
391 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
392 echo $my_result;
393 } else {
394 return $my_result;
395 }
396 return;
397 }
398 }
399
400 $start_script_code = wpbc__calendar__load( array(
401 'resource_id' => $resource_id,
402 'aggregate_resource_id_arr' => $additional_bk_types,
403 'selected_dates_without_calendar' => '',
404 'calendar_number_of_months' => $cal_count,
405 'start_month_calendar' => $start_month_calendar,
406 'custom_form' => 'standard' // Because we show only 'AVAILABILITY CALENDAR' without the form, at all.
407 ));
408
409 $my_result = '<div style="clear:both;height:10px;"></div>' . $this->pre_get_calendar_html( $resource_id, $cal_count, $bk_otions );
410
411 $my_result .= ' ' . $start_script_code ;
412
413 $my_result = apply_filters('wpdev_booking_calendar', $my_result , $resource_id);
414
415
416 $booking_form_is_using_bs_css = get_bk_option( 'booking_form_is_using_bs_css' );
417 $my_result = '<span ' . (($booking_form_is_using_bs_css == 'On') ? 'class="wpdevelop"' : '') . '>' . $my_result . '</span>';
418
419 make_bk_action('finish_check_multiuser_params_for_client_side', $resource_id );
420
421 if ( $is_echo ) {
422 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
423 echo $my_result;
424 } else {
425 return $my_result;
426 }
427 }
428
429 // Get content at client side of C A L E N D A R
430 function get__client_side_booking_content( $resource_id = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $cal_count = 1, $bk_otions = array() ) {
431
432 $nl = '<div style="clear:both;height:10px;"></div>'; // New line
433 if ($my_selected_dates_without_calendar=='') {
434 // Get HTML with [calendar] shortcode and Styles for calendar. Get legend html.
435 $calendar = $this->pre_get_calendar_html( $resource_id, $cal_count, $bk_otions );
436 } else {
437 $calendar = '<textarea rows="3" cols="50" id="date_booking' . $resource_id . '" name="date_booking' . $resource_id . '" autocomplete="off" style="display:none;">' . $my_selected_dates_without_calendar . '</textarea>'; // Calendar code
438 }
439
440 // FixIn: 8.2.1.1.
441 $form = '<a name="bklnk' . $resource_id . '" id="bklnk' . $resource_id . '"></a><div id="booking_form_div' . $resource_id . '" class="booking_form_div">';
442 // FixIn: 6.0.1.5.
443 $custom_params = array();
444 if (! empty($bk_otions)) {
445 $param ='\s*([name|value]+)=[\'"]{1}([^\'"]+)[\'"]{1}\s*'; // Find all possible options
446 $pattern_to_search='%\s*{([^\s]+)' . $param . $param .'}\s*[,]?\s*%';
447 preg_match_all($pattern_to_search, $bk_otions, $matches, PREG_SET_ORDER);
448 //debuge($matches);
449 foreach ( $matches as $matche_value ) {
450 if ( $matche_value[1] == 'parameter' ) {
451 $custom_params[ $matche_value[3] ]= $matche_value[5];
452 }
453 }
454 }
455 // FixIn: 6.0.1.5.
456
457 if ( $this->wpdev_bk_personal !== false ) {
458 $form .= $this->wpdev_bk_personal->get_booking_form( $resource_id, $my_booking_form, $custom_params );
459 } else {
460 $form .= wpbc_simple_form__get_booking_form__as_html( $resource_id );
461 }
462
463
464 // Insert calendar into form
465 if ( strpos( $form, '[calendar]' ) !== false ) {
466 $form = str_replace( '[calendar]', $calendar, $form );
467 } else {
468 $form = '<div class="booking_form_div">' . $calendar . '</div>' . $nl . $form;
469 }
470
471 // Replace additional calendars like [calendar id=9] to HTML and JS code
472 $form = apply_bk_filter( 'wpdev_check_for_additional_calendars_in_form'
473 , $form
474 , $resource_id
475 , array(
476 'booking_form' => $my_booking_form ,
477 'selected_dates' => $my_selected_dates_without_calendar ,
478 'cal_count' => $cal_count ,
479 'otions' => $bk_otions
480 )
481 );
482
483 if ( strpos($form, '[captcha]') !== false ) {
484 $captcha = $this->createCapthaContent($resource_id);
485 $form =str_replace('[captcha]', $captcha ,$form);
486 }
487
488 // Set additional "Check in/out" times, if activated to use change-over days!
489 $form = apply_filters( 'wpbc_booking_form_html__update__append_change_over_times', $form, $resource_id );
490
491
492
493 // Add booking type field
494 $form .= '<input id="bk_type' . $resource_id . '" name="bk_type' . $resource_id . '" class="" type="hidden" value="' . $resource_id . '" /></div>';
495 $submitting = '<div id="submiting' . $resource_id . '"></div><div class="form_bk_messages" id="form_bk_messages' . $resource_id . '" ></div>';
496
497 //Params: $action = -1, $name = "_wpnonce", $referer = true , $echo = true
498
499 $wpbc_nonce = wp_nonce_field('CALCULATE_THE_COST', ( "wpbc_nonceCALCULATE_THE_COST" . $resource_id) , true , false );
500
501
502 $res = $form . $submitting . $wpbc_nonce;
503
504 $my_random_id = time() * wp_rand(0,1000);
505 $my_random_id = 'form_id'. $my_random_id;
506
507 $booking_form_is_using_bs_css = get_bk_option( 'booking_form_is_using_bs_css');
508 $booking_form_format_type = get_bk_option( 'booking_form_format_type');
509 $booking_form_theme = get_bk_option( 'booking_form_theme');
510
511 $return_form = '<div id="' . $my_random_id . '" '
512 . ' class="wpbc_container wpbc_form wpbc_container_booking_form '
513 . ( ( wpbc_is_this_demo() == 'On' ) ? 'wpbc_demo_site ' : '' )
514 . esc_attr( $booking_form_theme ) . ' '
515 . ( ( $booking_form_is_using_bs_css == 'On' ) ? 'wpdevelop ' : '' )
516 . '" >' .
517 '<form id="booking_form' . $resource_id . '" class="booking_form ' . $booking_form_format_type . '" method="post" action="">' .
518 '<div id="ajax_respond_insert' . $resource_id . '" class="ajax_respond_insert" style="display:none;"></div>' .
519 $res.
520 '</form></div>';
521
522 $return_form .= '<div id="booking_form_garbage' . $resource_id . '" class="booking_form_garbage"></div>';
523
524 if ($my_selected_dates_without_calendar == '' ) {
525 // Check according already shown Booking Calendar and set do not visible of it
526
527 $return_form .= '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7.
528 $return_form .= ' jQuery(".widget_wpdev_booking .booking_form.form-horizontal").removeClass("form-horizontal");
529 var visible_calendars_count = _wpbc.get_other_param( "calendars__on_this_page" ).length;
530 if (visible_calendars_count !== null ) {
531 for (var i=0;i< visible_calendars_count ;i++){
532 if ( _wpbc.get_other_param( "calendars__on_this_page" )[i] === ' . $resource_id . ' ) {
533 document.getElementById("'.$my_random_id.'").innerHTML = "<span style=\'color:#A00;font-size:10px;\'>'.
534 /* translators: 1: ... */
535 esc_js( sprintf( __( '%1$sWarning! Booking calendar for this booking resource are already at the page, please check more about this issue at %2$sthis page%3$s', 'booking' )
536 , ''
537 , ''
538 , ': https://wpbookingcalendar.com/faq/why-the-booking-calendar-widget-not-show-on-page/'
539 ) )
540 .'</span>";
541 jQuery("#'.$my_random_id.'").animate( {opacity: 1}, 10000 ).fadeOut(5000);
542 return;
543 }
544 }
545 _wpbc.get_other_param( "calendars__on_this_page" )[ visible_calendars_count ]=' . intval( $resource_id ) . ';
546 } ';
547 $return_form .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7.
548 } else {
549 //FixIn:6.1.1.16 // FixIn: 8.2.1.13.
550 $return_form .= '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7.
551 $return_form .= ' if(typeof( showCostHintInsideBkForm ) == "function") { showCostHintInsideBkForm(' . $resource_id . '); } ';
552 $return_form .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7.
553 }
554
555 $is_use_auto_fill_for_logged = get_bk_option( 'booking_is_use_autofill_4_logged_user' ) ;
556
557
558 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
559 if (! isset($_GET['booking_hash']))
560 if ($is_use_auto_fill_for_logged == 'On') {
561
562 $curr_user = wpbc_get_current_user();
563 if ( $curr_user->ID > 0 ) {
564 $user_nick_name = get_user_meta( $curr_user->ID, 'nickname' );
565 $user_nick_name = ( empty( $user_nick_name ) ) ? '' : $user_nick_name[0]; // FixIn: 8.7.1.5.
566
567 $return_form .= '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7.
568 $return_form .= 'var bk_af_submit_form = document.getElementById( "booking_form' . $resource_id . '" );
569 var bk_af_count = bk_af_submit_form.elements.length;
570 var bk_af_element;
571 var bk_af_reg;
572 for (var bk_af_i=0; bk_af_i<bk_af_count; bk_af_i++) {
573 bk_af_element = bk_af_submit_form.elements[bk_af_i];
574 // FixIn: 9.4.3.4.
575 if ( ( bk_af_element.type == "text" ) || ( bk_af_element.type == "email" ) )
576 if ( bk_af_element.name !== ("date_booking' . $resource_id . '" ) )
577 {
578 // NickName // FixIn: 8.6.1.2.
579 bk_af_reg = /^([A-Za-z0-9_\-\.])*(nickname){1}([A-Za-z0-9_\-\.])*$/;
580 if(bk_af_reg.test(bk_af_element.name) != false)
581 if (bk_af_element.value == "" )
582 bk_af_element.value = "' . str_replace( "'", '', $user_nick_name ) . '";
583 // Second Name
584 bk_af_reg = /^([A-Za-z0-9_\-\.])*(last|second){1}([_\-\.])?name([A-Za-z0-9_\-\.])*$/;
585 if(bk_af_reg.test(bk_af_element.name) != false)
586 if (bk_af_element.value == "" )
587 bk_af_element.value = "'.str_replace("'",'',$curr_user->last_name).'";
588 // First Name
589 bk_af_reg = /^name([0-9_\-\.])*$/;
590 if(bk_af_reg.test(bk_af_element.name) != false)
591 if (bk_af_element.value == "" )
592 bk_af_element.value = "'.str_replace("'",'',$curr_user->first_name).'";
593 bk_af_reg = /^([A-Za-z0-9_\-\.])*(first|my){1}([_\-\.])?name([A-Za-z0-9_\-\.])*$/;
594 if(bk_af_reg.test(bk_af_element.name) != false)
595 if (bk_af_element.value == "" )
596 bk_af_element.value = "'.str_replace("'",'',$curr_user->first_name).'";
597 // Email
598 bk_af_reg = /^(e)?([_\-\.])?mail([0-9_\-\.])*$/;
599 if(bk_af_reg.test(bk_af_element.name) != false)
600 if (bk_af_element.value == "" )
601 bk_af_element.value = "'.str_replace("'",'',$curr_user->user_email).'";
602 // Phone
603 bk_af_reg = /^([A-Za-z0-9_\-\.])*(phone|fone){1}([A-Za-z0-9_\-\.])*$/;
604 if(bk_af_reg.test(bk_af_element.name) != false)
605 if (bk_af_element.value == "" )
606 bk_af_element.value = "'.str_replace("'",'',$curr_user->phone_number).'";
607 // NB Enfants
608 bk_af_reg = /^(e)?([_\-\.])?nb_enfant([0-9_\-\.])*$/;
609 if(bk_af_reg.test(bk_af_element.name) != false)
610 if (bk_af_element.value == "" )
611 bk_af_element.value = "'.str_replace("'",'',$curr_user->nb_enfant).'";
612 // URL
613 bk_af_reg = /^([A-Za-z0-9_\-\.])*(URL|site|web|WEB){1}([A-Za-z0-9_\-\.])*$/;
614 if(bk_af_reg.test(bk_af_element.name) != false)
615 if (bk_af_element.value == "" )
616 bk_af_element.value = "'.str_replace("'",'',$curr_user->user_url).'";
617 }
618 }';
619 $return_form .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7.
620 }
621 }
622
623 return $return_form ;
624 }
625 // </editor-fold>
626
627
628 // FixIn: 8.7.11.13.
629 function wpbc_test_speed_shortcode( $attr ) {
630
631 if ( wpbc_is_on_edit_page() ) {
632 return wpbc_get_preview_for_shortcode( 'booking_test_speed', $attr ); // FixIn: 9.9.0.39.
633 }
634
635 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
636
637 echo '<h4>Booking Calendar Test</h4>';
638
639 $datesArray = Array(
640 '2021-09-10'
641 , '2021-09-11'
642 , '2021-09-12'
643 , '2021-09-13'
644 , '2021-09-14'
645 , '2021-09-15'
646 , '2021-09-16'
647 , '2021-09-17'
648 , '2021-09-18'
649 ) ;
650 for( $i = 0; $i < 1 ; $i++) {
651 $result = wpbc_api_is_dates_booked( $datesArray, $resource_id = 13 );
652 //debuge((int) $result );
653 }
654
655 debuge_speed('(int)');
656 echo '<hr/>';
657 echo '<hr/>';
658 }
659
660
661 // <editor-fold defaultstate="collapsed" desc=" S H O R T C O D E S ">
662
663 // FixIn: 8.1.3.5.
664 /** Listing customners bookings in timeline view
665 *
666 * @param $attr - The same parameters as for bookingtimeline shortcode (function)
667 *
668 * @return mixed|string|void
669 */
670 function bookingcustomerlisting_shortcode( $attr ){
671
672 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
673 return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> ';
674 }
675
676 if ( wpbc_is_on_edit_page() ) {
677 return wpbc_get_preview_for_shortcode( 'bookingcustomerlisting', $attr ); // FixIn: 9.9.0.39.
678 }
679
680 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
681
682 // FixIn: 8.4.5.11.
683 if (! is_array($attr)) {
684 $attr = array();
685 }
686 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
687 if ( ( isset( $_GET['booking_hash'] ) ) || ( isset( $attr['booking_hash'] ) ) ) {
688
689
690 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
691 if ( isset( $_GET['booking_hash'] ) ) {
692 $get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
693 $my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $get_booking_hash );
694
695 $attr['booking_hash'] = $get_booking_hash;
696 } else {
697 $my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $attr['booking_hash'] );
698 }
699
700 if ( $my_booking_id_type !== false ) {
701
702 if ( ! isset( $attr['type' ] ) ) { // 8.1.3.5.2
703
704 $br_list = wpbc_get_all_booking_resources_list();
705 $br_list = array_keys( $br_list );
706 $br_list = implode(',',$br_list);
707 $attr['type' ] = $br_list; //wpbc_get_default_resource();
708 }
709 if ( ! isset( $attr['view_days_num' ] ) ) {
710 $attr['view_days_num' ] = 30;
711 }
712 if ( ! isset( $attr['scroll_start_date' ] ) ) {
713 $attr['scroll_start_date' ] = '';
714 }
715 if ( ! isset( $attr['scroll_day' ] ) ) {
716 $attr['scroll_day' ] = 0;
717 }
718 if ( ! isset( $attr['scroll_month' ] ) ) {
719 $attr['scroll_month' ] = 0;
720 }
721 if ( ! isset( $attr['header_title' ] ) ) {
722 $attr['header_title' ] = __( 'My bookings' , 'booking');
723 }
724
725 $timeline_results = $this->bookingtimeline_shortcode( $attr );
726
727 return $timeline_results ;
728
729 } else {
730 return '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . esc_html__('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking');
731 }
732
733 } else {
734 return __( 'This page can only be accessed through links in emails related to your booking.', 'booking' )
735 . ' <br/><em>'
736 /* translators: 1: ... */
737 . sprintf( __( 'Please check more about configuration at %1$sthis page%2$s', 'booking' ), '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/" target="_blank">', '</a>.' )
738 . '</em>';
739 }
740 }
741
742
743 /**
744 * TimeLine shortcode
745 *
746 * @param type $attr
747 * @return type
748 *
749 * Shortcodes exmaples:
750 *
751 *
752 ** Matrix:
753 * 1 Month View Mode:
754 [bookingtimeline type="3,4,1,5,6,7,8,9,2,10,11,12,14" view_days_num=30 scroll_start_date="" scroll_month=0 header_title='All Bookings']
755 * 2 Months View Mode:
756 [bookingtimeline type="1,5,6,7,8,9,2,10,11,12,3,4,14" view_days_num=60 scroll_start_date="" scroll_month=-1 header_title='All Bookings']
757 * 1 Week View Mode:
758 [bookingtimeline type="3,4" view_days_num=7 scroll_start_date="" scroll_day=-7 header_title='All Bookings']
759 * 1 Day View Mode:
760 [bookingtimeline type="3,4" view_days_num=1 scroll_start_date="" scroll_day=0 header_title='All Bookings']
761
762 ** Single:
763 * 1 Month View Mode:
764 [bookingtimeline type="4" view_days_num=30 scroll_start_date="" scroll_day=-15 scroll_month=0 header_title='All Bookings']
765 * 3 Months View Mode:
766 [bookingtimeline type="4" view_days_num=90 scroll_start_date="" scroll_day=-30]
767 * 1 Year View Mode:
768 [bookingtimeline type="4" view_days_num=365 scroll_start_date="" scroll_month=-3]
769
770
771 */
772 function bookingtimeline_shortcode($attr) {
773
774 if ( wpbc_is_on_edit_page() ) {
775 return wpbc_get_preview_for_shortcode( 'bookingtimeline', $attr ); // FixIn: 9.9.0.39.
776 }
777
778 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
779
780 // FixIn: 8.6.1.13.
781 $timeline_results = bookingflextimeline_shortcode($attr);
782 return $timeline_results;
783 }
784
785 // Replace MARK at post with content at client side ----- [booking nummonths='1' type='1']
786 function booking_shortcode($attr) {
787
788 if ( wpbc_is_on_edit_page() ) {
789 return wpbc_get_preview_for_shortcode( 'booking', $attr ); // FixIn: 9.9.0.39.
790 }
791
792 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
793
794 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
795 if ( isset( $_GET['booking_hash'] ) ) {
796 return
797 __( 'You need to use special shortcode [bookingedit] for booking editing.', 'booking' )
798 . ' '
799 /* translators: 1: ... */
800 . sprintf( __( 'Please check FAQ instruction how to configure it here %s', 'booking' )
801 , '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/">https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/</a>'
802 );
803 }
804
805 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
806
807 $my_boook_count = get_bk_option( 'booking_client_cal_count' );
808 $my_boook_type = 1;
809 $my_booking_form = 'standard';
810 $start_month_calendar = false;
811 $bk_otions = array();
812
813 if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; }
814
815 if ( isset( $attr['resource_id'] ) ) {
816 $attr['type'] = intval( $attr['resource_id'] ); // FixIn: 10.2.2.2.
817 }
818 if ( isset( $attr['type'] ) ) {
819 $my_boook_type = intval( $attr['type'] ); // FixIn: 10.2.2.2.
820 }
821
822 if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; }
823
824 if ( isset( $attr['agregate'] ) && (! empty( $attr['agregate'] )) ) {
825 $additional_bk_types = $attr['agregate'];
826 $my_boook_type .= ';'.$additional_bk_types;
827 }
828 if ( isset( $attr['aggregate'] ) && (! empty( $attr['aggregate'] )) ) {
829 $additional_bk_types = $attr['aggregate'];
830 $my_boook_type .= ';'.$additional_bk_types;
831 }
832
833
834 if ( isset( $attr['startmonth'] ) ) { // Set start month of calendar, fomrat: '2011-1'
835
836 $start_month_calendar = explode( '-', $attr['startmonth'] );
837 if ( (is_array($start_month_calendar)) && ( count($start_month_calendar) > 1) ) { }
838 else $start_month_calendar = false;
839
840 }
841
842 if ( isset( $attr['options'] ) ) { $bk_otions = $attr['options']; }
843
844 $res = $this->add_booking_form_action( $my_boook_type, $my_boook_count, 0, $my_booking_form, '', $start_month_calendar, $bk_otions );
845
846 return $res;
847 }
848
849 // Replace MARK at post with content at client side ----- [booking nummonths='1' type='1']
850 function booking_calendar_only_shortcode($attr) {
851
852 if ( wpbc_is_on_edit_page() ) {
853 return wpbc_get_preview_for_shortcode( 'bookingcalendar', $attr ); // FixIn: 9.9.0.39.
854 }
855
856 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
857
858 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
859
860 $my_boook_count = get_bk_option( 'booking_client_cal_count' );
861 $my_boook_type = 1;
862 $start_month_calendar = false;
863 $bk_otions = array();
864 if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; }
865 if ( isset( $attr['resource_id'] ) ) {
866 $attr['type'] = intval( $attr['resource_id'] ); // FixIn: 10.2.2.2.
867 }
868 if ( isset( $attr['type'] ) ) {
869 $my_boook_type = intval( $attr['type'] ); // FixIn: 10.2.2.2.
870 }
871 if ( isset( $attr['agregate'] ) && (! empty( $attr['agregate'] )) ) {
872 $additional_bk_types = $attr['agregate'];
873 $my_boook_type .= ';'.$additional_bk_types;
874 }
875 if ( isset( $attr['aggregate'] ) && (! empty( $attr['aggregate'] )) ) { // FixIn: 8.3.3.8.
876 $additional_bk_types = $attr['aggregate'];
877 $my_boook_type .= ';'.$additional_bk_types;
878 }
879
880 if ( isset( $attr['startmonth'] ) ) { // Set start month of calendar, fomrat: '2011-1'
881 $start_month_calendar = explode( '-', $attr['startmonth'] );
882 if ( (is_array($start_month_calendar)) && ( count($start_month_calendar) > 1) ) { }
883 else $start_month_calendar = false;
884 }
885
886 if ( isset( $attr['options'] ) ) { $bk_otions = $attr['options']; }
887 $res = $this->add_calendar_action($my_boook_type,$my_boook_count, 0, $start_month_calendar, $bk_otions );
888
889
890 $start_script_code = "<div id='calendar_booking_unselectable".$my_boook_type."'></div>";
891 return "<div class='wpbc_only_calendar wpbc_container'>" . $start_script_code . $res . '</div>'; // FixIn: 8.0.1.2.
892 }
893
894 // Show only booking form, with already selected dates
895 function bookingform_shortcode($attr) {
896
897 if ( wpbc_is_on_edit_page() ) {
898 return wpbc_get_preview_for_shortcode( 'bookingform', $attr ); // FixIn: 9.9.0.39.
899 }
900
901 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
902
903 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
904
905 $my_boook_type = 1;
906 $my_booking_form = 'standard';
907 $my_boook_count = 1;
908 $my_selected_dates_without_calendar = '';
909
910 if ( isset( $attr['resource_id'] ) ) {
911 $attr['type'] = intval( $attr['resource_id'] ); // FixIn: 10.2.2.2.
912 }
913 if ( isset( $attr['type'] ) ) {
914 $my_boook_type = intval( $attr['type'] ); // FixIn: 10.2.2.2.
915 }
916 if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; }
917 if ( isset( $attr['selected_dates'] ) ) { $my_selected_dates_without_calendar = $attr['selected_dates']; } //$my_selected_dates_without_calendar = '20.08.2010, 29.08.2010';
918
919 $res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form, $my_selected_dates_without_calendar, false );
920
921 return $res;
922 }
923
924
925 // Show booking form for editing
926 function bookingedit_shortcode($attr) {
927
928 if ( wpbc_is_on_edit_page() ) {
929 return wpbc_get_preview_for_shortcode( 'bookingedit', $attr ); // FixIn: 9.9.0.39.
930 }
931
932 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
933
934
935 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
936
937 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
938 if ( isset( $_GET['wpbc_hash'] ) ) {
939
940 if ( function_exists( 'wpbc_parse_one_way_hash' ) ) {
941
942 $get_wpbc_hash = ( ( isset( $_GET['wpbc_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['wpbc_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
943
944 $one_way_hash_response = wpbc_parse_one_way_hash( $get_wpbc_hash );
945
946 return $one_way_hash_response;
947 }
948 }
949
950 $my_boook_count = get_bk_option( 'booking_client_cal_count' );
951 $my_boook_type = 1;
952 $my_booking_form = 'standard';
953 $bk_otions = array();
954 if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; }
955 if ( isset( $attr['resource_id'] ) ) { $attr['type'] = $attr['resource_id']; }
956 if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; }
957 if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; }
958 if ( isset( $attr['agregate'] ) && (! empty( $attr['agregate'] )) ) { // FixIn: 7.0.1.26.
959 $additional_bk_types = $attr['agregate'];
960 $my_boook_type .= ';'.$additional_bk_types;
961 }
962 if ( isset( $attr['aggregate'] ) && (! empty( $attr['aggregate'] )) ) {
963 $additional_bk_types = $attr['aggregate'];
964 $my_boook_type .= ';'.$additional_bk_types;
965 }
966 if ( isset( $attr['options'] ) ) { $bk_otions = $attr['options']; }
967
968
969 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
970 if (isset($_GET['booking_hash'])) {
971 $get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
972 $my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $get_booking_hash );
973 if ($my_booking_id_type !== false) {
974 $my_edited_bk_id = $my_booking_id_type[0];
975 $my_boook_type = $my_booking_id_type[1];
976 if ($my_boook_type == '') return '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . esc_html__('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking');
977 } else {
978 return '<strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' . esc_html__('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking');
979 }
980
981 } else {
982 return __('This page can only be accessed through links in emails related to your booking.' ,'booking')
983 . ' <br/><em>'
984 /* translators: 1: ... */
985 . sprintf( __( 'Please check more about configuration at %1$sthis page%2$s', 'booking' )
986 , '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/" target="_blank">' , '</a>.')
987 . '</em>';
988 }
989
990
991 $res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form, '', false, $bk_otions );
992
993 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
994 if (isset($_GET['booking_pay'])) {
995 // Payment form
996 if ( 'On' == get_bk_option( 'booking_super_admin_receive_regular_user_payments' ) ){ // FixIn: 9.2.3.8.
997 make_bk_action('make_force_using_this_user', -999 ); // '-999' - This ID "by default" is the ID of super booking admin user
998 }
999
1000 $get_booking_hash = ( ( isset( $_GET['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_GET['booking_hash'] ) ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */
1001 $res = wpbc_do_shortcode__booking_confirm( array(
1002 'booking_hash' => $get_booking_hash
1003 ) );
1004
1005 if ( 'On' == get_bk_option( 'booking_super_admin_receive_regular_user_payments' ) ){ // FixIn: 9.2.3.8.
1006 make_bk_action( 'finish_force_using_this_user' );
1007 }
1008
1009 }
1010
1011 return $res;
1012 }
1013
1014 // Search form
1015 function bookingsearch_shortcode($attr) {
1016
1017 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
1018 return '<strong>' . esc_html__( 'This shortcode available in Pro versions, only!', 'booking' ) . '</strong> ';
1019 }
1020
1021 if ( wpbc_is_on_edit_page() ) {
1022 return wpbc_get_preview_for_shortcode( 'bookingsearch', $attr ); // FixIn: 9.9.0.39.
1023 }
1024
1025 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
1026
1027 $search_form = '';
1028
1029 if ( function_exists( 'wpbc_search_avy__show_search_form' ) ) {
1030
1031 ob_start();
1032
1033 $search_form_content = wpbc_search_avy__show_search_form( $attr );
1034
1035 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1036 echo $search_form_content;
1037
1038 $search_form = ob_get_clean();
1039 }
1040
1041 return $search_form ;
1042 }
1043
1044 /**
1045 * Search Results Shortcode -- Show 'Search Results' at New Page
1046 *
1047 * @param $attr
1048 *
1049 * @return string
1050 */
1051 function bookingsearchresults_shortcode($attr) {
1052
1053 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
1054 return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> ';
1055 }
1056
1057 if ( wpbc_is_on_edit_page() ) {
1058 return wpbc_get_preview_for_shortcode( 'bookingsearchresults', $attr ); // FixIn: 9.9.0.39.
1059 }
1060
1061 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
1062
1063 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
1064
1065 $search_results_to_show = '';
1066 if ( function_exists( 'wpbc_search_avy__show_search_results' ) ) {
1067
1068 ob_start();
1069
1070 wpbc_search_avy__show_search_results( $attr ); // FixIn: 10.0.0.37.
1071
1072 $search_results_to_show .= ob_get_clean();
1073 }
1074
1075 return $search_results_to_show;
1076 }
1077
1078
1079 // Select Booking form using the selectbox
1080 function bookingselect_shortcode($attr) {
1081
1082 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
1083 return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> ';
1084 }
1085
1086 if ( wpbc_is_on_edit_page() ) {
1087 return wpbc_get_preview_for_shortcode( 'bookingselect', $attr ); // FixIn: 9.9.0.39.
1088 }
1089
1090 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
1091
1092 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
1093
1094 $search_form = apply_bk_filter('wpdev_get_booking_select_form','', $attr );
1095
1096 return $search_form ;
1097 }
1098
1099 // Select Booking form using the selectbox
1100 function bookingresource_shortcode($attr) {
1101
1102 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
1103 return '<strong>' . esc_html__('This shortcode available in Pro versions, only!' ,'booking') . '</strong> ';
1104 }
1105
1106 if ( wpbc_is_on_edit_page() ) {
1107 return wpbc_get_preview_for_shortcode( 'bookingresource', $attr ); // FixIn: 9.9.0.39.
1108 }
1109
1110 $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
1111
1112 //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
1113
1114 $search_form = apply_bk_filter('wpbc_booking_resource_info','', $attr );
1115
1116 return $search_form ;
1117 }
1118
1119
1120 // </editor-fold>
1121 }