PluginProbe
Booking Calendar / 11.8.4
Booking Calendar v11.8.4
11.8.4 11.8.3 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 All 204 releases
← All changes | includes/page-availability/availability__page.php +101 -68 10.1.311.8.4 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /*
3 3 * @package: AJX_Bookings Page
4 4 * @category: o Email Reminders
@@ -20,41 +20,42 @@
20 20 */
21 21 class WPBC_Page_AJX_Availability extends WPBC_Page_Structure {
22 22
23 23
24 - public function __construct() {
24 + public function __construct() {
25 25
26 - parent::__construct();
26 + parent::__construct();
27 27
28 - add_action( 'wpbc_toolbar_top_tabs_after', array( $this, 'wpbc_toolbar_toolbar_tabs' ) );
29 28 add_action( 'wpbc_toolbar_top_tabs_insert', array( $this, 'wpbc_toolbar_toolbar_tabs' ) );
30 - }
29 + }
31 30
32 31
33 - public function in_page() {
34 - return 'wpbc-availability';
35 - }
32 + public function in_page() {
33 + return 'wpbc-availability';
34 + }
36 35
37 36
38 37 public function tabs() {
39 -
40 - $tabs = array();
41 - $tabs[ 'availability' ] = array(
42 - 'title' => __( 'Days Availability', 'booking' ) // Title of TAB //FixIn: 9.8.15.2.2
43 - , 'hint' => __( 'Define available and unavailable days for calendar(s)', 'booking' ) // Hint
44 - , 'page_title' => __( 'Calendar Availability', 'booking' ) // Title of Page
45 - , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
46 - , 'position' => '' // 'left' || 'right' || ''
47 - , 'css_classes' => '' // CSS class(es)
48 - , 'icon' => '' // Icon - link to the real PNG img
49 - , 'font_icon' => 'wpbc-bi-calendar2-check'//'wpbc_icn_free_cancellation' // CSS definition of forn Icon
50 - , 'default' => true // Is this tab activated by default or not: true || false.
51 - , 'disabled' => false // Is this tab disbaled: true || false.
52 - , 'hided' => false // Is this tab hided: true || false.
53 - , 'subtabs' => array()
54 - );
55 - // $subtabs = array();
56 - // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
38 + $tabs = array();
39 + $tabs['availability'] = array(
40 + 'is_show_top_path' => true, // true | false. By default value is: true.
41 + 'left_navigation__default_view_mode' => '', // FixIn:11.7.1.1: 'compact', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
42 + 'title' => __( 'Block Dates', 'booking' ), // Title of TAB //FixIn: 9.8.15.2.2.
43 + 'hint' => __( 'Define available and unavailable days for your calendar(s).', 'booking' ), // Hint.
44 + 'page_title' => __( 'Block Dates', 'booking' ), // Title of Page.
45 + 'link' => '', // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link.
46 + 'position' => '', // 'left' / 'right' / ''.
47 + 'css_classes' => '', // CSS c l a s s(es).
48 + 'icon' => '', // Icon - link to the real PNG img.
49 + 'font_icon' => 'wpbc-bi-calendar2-check', // 'wpbc_icn_free_cancellation' // CSS definition of forn Icon.
50 + 'font_icon_right' => 'wpbc-bi-question-circle',
51 + 'default' => true, // Is this tab activated by default or not: true || false.
52 + 'disabled' => false, // Is this tab disbaled: true || false.
53 + 'hided' => false, // Is this tab hided: true || false.
54 + 'subtabs' => array(),
55 + 'folder_style' => 'order:91;',
56 + 'is_show_top_navigation' => true,
57 + );
57 58 return $tabs;
58 59 }
59 60
60 61
@@ -62,26 +63,24 @@
62 63 * Show custom tabs for Toolbar at . - . R i g h t . s i d e.
63 64 *
64 65 * @param string $menu_in_page_tag - active page
65 66 */
66 - public function wpbc_toolbar_toolbar_tabs( $menu_in_page_tag ) {
67 + public function wpbc_toolbar_toolbar_tabs( $menu_in_page_tag ) {
67 68
68 - if (
69 - ( $this->in_page() == $menu_in_page_tag )
70 - && ( ( empty( $_GET['tab'] ) ) || ( 'availability' == $_GET['tab'] ) ) //FixIn: 9.8.15.2.2
71 - ) {
69 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
70 + if ( ( $this->in_page() === $menu_in_page_tag ) && ( ( empty( $_GET['tab'] ) ) || ( 'availability' === $_GET['tab'] ) ) ) { // FixIn: 9.8.15.2.2.
72 71
73 - wpbc_bs_toolbar_tabs_html_container_start();
72 + wpbc_bs_toolbar_tabs_html_container_start();
74 73
75 - $escaped_search_request_params = $this->get_cleaned_params__saved_requestvalue_default();
74 + $escaped_search_request_params = $this->get_cleaned_params__saved_requestvalue_default();
76 75
77 - // Check if by some reason, user was saved request without this parameter, then get default value
78 - if ( ! empty( $escaped_search_request_params['ui_usr__availability_selected_toolbar'] ) ) {
79 - $selected_tab = $escaped_search_request_params['ui_usr__availability_selected_toolbar'];
80 - } else {
81 - $default_search_request_params = WPBC_AJX__Availability::request_rules_structure();
82 - $selected_tab = $default_search_request_params ['ui_usr__availability_selected_toolbar']['default'];
83 - }
76 + // Check if by some reason, user was saved request without this parameter, then get default value.
77 + if ( ! empty( $escaped_search_request_params['ui_usr__availability_selected_toolbar'] ) ) {
78 + $selected_tab = $escaped_search_request_params['ui_usr__availability_selected_toolbar'];
79 + } else {
80 + $default_search_request_params = WPBC_AJX__Availability::request_rules_structure();
81 + $selected_tab = $default_search_request_params ['ui_usr__availability_selected_toolbar']['default'];
82 + }
84 83
85 84 wpbc_bs_display_tab( array(
86 85 'title' => __( 'Set Availability', 'booking' )
87 86 , 'hint' => array( 'title' => __('Availability' ,'booking') , 'position' => 'top' )
@@ -153,13 +152,13 @@
153 152 )
154 153 );
155 154 $escaped_request_params_arr = $user_request->get_sanitized__saved__user_request_params(); // Get Saved
156 155
157 -//Fix Calendar cell heights in versions older than //FixIn: 9.7.3.2
156 +//Fix Calendar cell heights in versions older than // FixIn: 9.7.3.2.
158 157 if ( ( false !== $escaped_request_params_arr )
159 158 && ( '' === $escaped_request_params_arr['calendar__view__cell_height'] )
160 159 ) {
161 - $user_request->user_request_params__db_delete(); // Delete from DB
160 + $user_request->user_request_params__db_delete(); // Delete from DB.
162 161 }
163 162
164 163 if ( false === $escaped_request_params_arr ) { // This request was not saved before, then get sanitized direct parameters, like: $_REQUEST['resource_id']
165 164
@@ -166,9 +165,18 @@
166 165 $request_prefix = false;
167 166 $escaped_request_params_arr = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // Direct: $_REQUEST['resource_id']
168 167 }
169 168
169 + // Direct links from other admin tools can intentionally open availability for a specific resource.
170 + // In that case this URL value must override previously saved user toolbar state.
171 + if ( false !== wpbc_get_direct_value_in_request( 'resource_id', false ) ) {
172 + $direct_request_params_arr = $user_request->get_sanitized__in_request__value_or_default( false );
173 + if ( ! empty( $direct_request_params_arr['resource_id'] ) ) {
174 + $escaped_request_params_arr['resource_id'] = $direct_request_params_arr['resource_id'];
175 + }
176 + }
170 177
178 +
171 179 //MU
172 180 if ( class_exists( 'wpdev_bk_multiuser' ) ) {
173 181
174 182 // Check if this MU user activated or superadmin, otherwise show warning
@@ -204,9 +212,9 @@
204 212 $escaped_request_params_arr = $this->get_cleaned_params__saved_requestvalue_default();
205 213
206 214 // During initial load of the page, we need to reset 'dates_selection' value in our saved parameter
207 215 $escaped_request_params_arr['dates_selection'] = '';
208 - $escaped_request_params_arr['calendar__start_week_day'] = get_bk_option( 'booking_start_day_weeek' );
216 + $escaped_request_params_arr['calendar__start_week_day'] = intval(get_bk_option( 'booking_start_day_weeek' ));
209 217
210 218
211 219 // Submit /////////////////////////////////////////////////////////////
212 220 $submit_form_name = 'wpbc_ajx_availability_form'; // Define form name
@@ -214,8 +222,9 @@
214 222 ?><span class="wpdevelop"><?php // BS UI CSS Class
215 223
216 224 wpbc_js_for_bookings_page(); // JavaScript functions
217 225
226 + $this->wpbc_toolbar_toolbar_tabs( $this->in_page() );
218 227 wpbc_ajx_availability__toolbar( $escaped_request_params_arr );
219 228
220 229 ?></span><?php
221 230
@@ -224,13 +233,13 @@
224 233 // Content ////////////////////////////////////////////////////////////
225 234 ?>
226 235 <div class="clear" style="margin-bottom:10px;"></div>
227 236 <span class="metabox-holder">
228 - <form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post" >
237 + <form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" >
229 238 <?php
230 239 // N o n c e field, and key for checking S u b m i t
231 240 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
232 - ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" /><?php
241 + ?><input type="hidden" name="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" id="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" value="1" /><?php
233 242
234 243 //wpbc_ajx_booking_modify_container_show(); // Container for showing Edit ajx_booking and define Edit and Delete ajx_booking JavaScript vars.
235 244
236 245 wpbc_clear_div();
@@ -251,9 +260,9 @@
251 260 private function ajx_availability_container__show( $escaped_request_params_arr ) {
252 261
253 262 ?>
254 263 <div id="ajx_nonce_calendar_section"></div>
255 - <div class="wpbc_listing_container wpbc_selectable_table wpbc_ajx_availability_container wpdevelop" wpbc_loaded="first_time">
264 + <div class="wpbc_ajx_availability_container wpbc_selectable_table wpdevelop" wpbc_loaded="first_time">
256 265 <style type="text/css">
257 266 .wpbc_calendar_loading .wpbc_icn_autorenew::before{
258 267 font-size: 1.2em;
259 268 }
@@ -264,9 +273,9 @@
264 273 font-size: 1.2em;
265 274 font-weight: 600;
266 275 }
267 276 </style>
268 - <div class="wpbc_calendar_loading"><span class="wpbc_icn_autorenew wpbc_spin"></span>&nbsp;&nbsp;<span><?php _e( 'Loading', 'booking' ); ?>...</span>
277 + <div class="wpbc_calendar_loading"><span class="wpbc_icn_autorenew wpbc_spin"></span>&nbsp;&nbsp;<span><?php esc_html_e( 'Loading', 'booking' ); ?>...</span>
269 278 </div>
270 279 </div>
271 280 <script type="text/javascript">
272 281 jQuery( document ).ready( function (){
@@ -271,11 +280,11 @@
271 280 <script type="text/javascript">
272 281 jQuery( document ).ready( function (){
273 282
274 283 // Set Security - Nonce for Ajax - Listing
275 - wpbc_ajx_availability.set_secure_param( 'nonce', '<?php echo wp_create_nonce( 'wpbc_ajx_availability_ajx' . '_wpbcnonce' ) ?>' );
276 - wpbc_ajx_availability.set_secure_param( 'user_id', '<?php echo wpbc_get_current_user_id(); ?>' );
277 - wpbc_ajx_availability.set_secure_param( 'locale', '<?php echo get_user_locale(); ?>' );
284 + wpbc_ajx_availability.set_secure_param( 'nonce', '<?php echo esc_js( wp_create_nonce( 'wpbc_ajx_availability_ajx' . '_wpbcnonce' ) ); ?>' );
285 + wpbc_ajx_availability.set_secure_param( 'user_id', '<?php echo esc_js( wpbc_get_current_user_id() ); ?>' );
286 + wpbc_ajx_availability.set_secure_param( 'locale', '<?php echo esc_js( get_user_locale() ); ?>' );
278 287
279 288 // Set other parameters
280 289 wpbc_ajx_availability.set_other_param( 'listing_container', '.wpbc_ajx_availability_container' );
281 290
@@ -283,23 +292,25 @@
283 292 wpbc_ajx_availability__send_request_with_params( <?php echo wp_json_encode( $escaped_request_params_arr ); ?> );
284 293 } );
285 294 </script>
286 295 <?php
287 -//FixIn: 10.0.0.5
296 +// FixIn: 10.0.0.5.
297 +/*
288 298 if ( 0 ) {
289 299 $resource_id = 220;
290 - // $bk_cal = apply_bk_filter( 'pre_get_calendar_html', $resource_id, $my_boook_count, $bk_otions );
300 + // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet // FixIn: 10.12.4.2.
301 + ?><style type="text/css" rel="stylesheet"> .hasDatepick .datepick-inline .datepick-title-row th, .hasDatepick .datepick-inline .datepick-days-cell { max-height: 50px; } </style><?php
302 +
291 303 ?>
292 - <style type="text/css" rel="stylesheet"> .hasDatepick .datepick-inline .datepick-title-row th, .hasDatepick .datepick-inline .datepick-days-cell { height: 50px; } </style>
293 304 <div class="wpbc_calendar_wraper wpbc_change_over_triangle">
294 305 <div class="bk_calendar_frame months_num_in_row_4 cal_month_num_4" style="width:100%;max-width:100%;">
295 - <div id="calendar_booking<?php echo $resource_id ?>"><?php _e('Calendar is loading...', 'booking'); ?></div>
306 + <div id="calendar_booking<?php echo esc_attr( $resource_id ); ?>"><?php esc_html_e('Calendar is loading...', 'booking'); ?></div>
296 307 </div>
297 308 </div><?php
298 309
299 310 $selected_dates_if_no_calendar = '';
300 - echo '<textarea rows="3" cols="50" id="date_booking' . $resource_id . '" name="date_booking' . $resource_id . '" autocomplete="off" style="display:none;">'
301 - . $selected_dates_if_no_calendar . '</textarea>';
311 + echo '<textarea rows="3" cols="50" id="date_booking' . esc_attr( $resource_id ) . '" name="date_booking' . esc_attr( $resource_id ) . '" autocomplete="off" style="display:none;">' .
312 + esc_textarea( $selected_dates_if_no_calendar ) . '</textarea>';
302 313 if(1){
303 314 $start_script_code = wpbc__calendar__load( array(
304 315
305 316 'resource_id' => $resource_id,
@@ -310,9 +321,9 @@
310 321 'shortcode_options' => '', // options from the Booking Calendar shortcode. Usually it's conditional dates selection parameters
311 322 'custom_form' => 'standard'
312 323
313 324 ));
314 -
325 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
315 326 echo $start_script_code;
316 327 } else {
317 328 ?>
318 329 <script type='text/javascript'> jQuery( document ).ready( function (){
@@ -329,11 +340,11 @@
329 340 _wpbc.calendar__set_param_value( 220, 'dynamic__days_specific', [] );
330 341 _wpbc.calendar__set_param_value( 220, 'dynamic__week_days__start', [-1] );
331 342 _wpbc.calendar__set_param_value( 220, 'booking_date_format', 'j M Y' );
332 343 _wpbc.calendar__set_param_value( 220, 'booking_time_format', 'g:i A' );
333 - _wpbc.set_message( 'message_dates_times_unavailable', 'These dates and times in this calendar are already booked or unavailable.' );
334 - _wpbc.set_message( 'message_choose_alternative_dates', 'Please choose alternative date(s), times, or adjust the number of slots booked.' );
335 - _wpbc.set_message( 'message_cannot_save_in_one_resource', 'It is not possible to store this sequence of the dates into the one same resource.' );
344 + _wpbc.set_message( 'message_dates_times_unavailable', <?php echo wp_json_encode( wpbc_frontend_messages__get( 'message_dates_times_unavailable' ) ); ?> );
345 + _wpbc.set_message( 'message_choose_alternative_dates', <?php echo wp_json_encode( wpbc_frontend_messages__get( 'message_choose_alternative_dates' ) ); ?> );
346 + _wpbc.set_message( 'message_cannot_save_in_one_resource', <?php echo wp_json_encode( wpbc_frontend_messages__get( 'message_cannot_save_in_one_resource' ) ); ?> );
336 347 _wpbc.calendar__set_param_value( 220, 'is_parent_resource', 0 );
337 348 _wpbc.calendar__set_param_value( 220, 'booking_capacity_field', 'visitors' );
338 349 _wpbc.calendar__set_param_value( 220, 'booking_is_dissbale_booking_for_different_sub_resources', 'Off' );
339 350 _wpbc.calendar__set_param_value( 220, 'booking_recurrent_time', 'Off' );
@@ -347,11 +358,11 @@
347 358 }
348 359 } );
349 360 _wpbc.seasons__set( 220, [] );
350 361 wpbc_calendar_show( '220' );
351 - _wpbc.set_secure_param( 'nonce', '<?php echo wp_create_nonce( 'wpbc_calendar_load_ajx' . '_wpbcnonce' ); ?>' );
352 - _wpbc.set_secure_param( 'user_id','<?php echo wpbc_get_current_user_id(); ?>' );
353 - _wpbc.set_secure_param( 'locale', '<?php echo get_user_locale(); ?>' );
362 + _wpbc.set_secure_param( 'nonce', '<?php echo esc_attr( wp_create_nonce( 'wpbc_calendar_load_ajx' . '_wpbcnonce' ) ); ?>' );
363 + _wpbc.set_secure_param( 'user_id','<?php echo esc_attr( wpbc_get_current_user_id() ); ?>' );
364 + _wpbc.set_secure_param( 'locale', '<?php echo esc_attr( get_user_locale() ); ?>' );
354 365 wpbc_calendar__load_data__ajx( {
355 366 "resource_id" : 220,
356 367 "booking_hash" : "",
357 368 "request_uri" : "\/2024-03-221132\/",
@@ -363,10 +374,10 @@
363 374 </script>
364 375 <?php
365 376 }
366 377 }
378 +*/
367 379
368 -
369 380 }
370 381
371 382 /**
372 383 * Hide first "Availability tab", because we have only one tab hhere, and need to show only tabs for toolbar
@@ -372,9 +383,9 @@
372 383 * Hide first "Availability tab", because we have only one tab hhere, and need to show only tabs for toolbar
373 384 * @return void
374 385 */
375 386 private function css_fix(){
376 - //FixIn: 9.8.15.2
387 + // FixIn: 9.8.15.2.
377 388 /*
378 389
379 390 ?><style type="text/css">
380 391 .nav-tabs .nav-tab:first-child{
@@ -396,10 +407,14 @@
396 407
397 408
398 409 public function in_page() {
399 410
411 + if ( class_exists( 'WPBC_Page_Availability_General_Dedicated' ) ) {
412 + return (string) wp_rand( 100000, 1000000 );
413 + }
414 +
400 415 if ( ! wpbc_is_mu_user_can_be_here( 'only_super_admin' ) ) { // If this User not "super admin", then do not load this page at all
401 - return (string) rand( 100000, 1000000 ); // If this User not "super admin", then do not load this page at all
416 + return (string) wp_rand( 100000, 1000000 ); // If this User not "super admin", then do not load this page at all
402 417 }
403 418
404 419 return 'wpbc-availability';
405 420 }
@@ -407,22 +422,40 @@
407 422
408 423
409 424 public function tabs() {
410 425
426 +
427 + $separator_i = 0;
428 + $subtab_default = array(
429 + 'type' => 'subtab', // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'.
430 + 'title' => '', // Example: __( 'Dashboard' // Title of TAB.
431 + 'page_title' => '', // __( 'Search Availability' // Title of Page.
432 + 'hint' => '', // __( 'Configure the layout and functionality of both the search form and search results.' // Hint.
433 + 'link' => '', // wpbc_get_settings_url() . '&scroll_to_section=wpbc_general_settings_dashboard_tab', // Link.
434 + 'css_classes' => '', // cls CSS .
435 + 'font_icon' => 'wpbc_icn_dashboard',
436 + 'font_icon_right' => 'wpbc-bi-question-circle', // 'wpbc-bi-question-circle' .
437 + 'default' => false, // Is this sub tab activated by default or not: true || false.
438 + );
439 +
411 440 $tabs = array();
441 + // FixIn: 10.12.4.7. $tabs[ 'general_availability' . ( ++$separator_i ) ] = array_merge( $subtab_default, array( 'type' => 'separator' ,'folder_style' => 'order:200;' ) );
412 442 $tabs[ 'general_availability' ] = array(
413 - 'title' => __( 'General Availability', 'booking' ) // Title of TAB //FixIn: 9.8.15.2.2
443 + 'title' => __( 'Schedule & Rules', 'booking' ) // Title of TAB //FixIn: 9.8.15.2.2
414 444 , 'hint' => __( 'Define unavailable weekdays for all calendar(s) and unavailable dates depend from today date', 'booking' ) // Hint
415 - , 'page_title' => __( 'General Availability', 'booking' ) // Title of Page
416 - , 'link' => wpbc_get_settings_url( true, false ) . '&scroll_to_section=wpbc_general_settings_availability_tab' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
445 + , 'page_title' => __( 'Schedule & Rules', 'booking' ) // Title of Page
446 + , 'link' => function_exists( 'wpbc_get_general_availability_url' ) ? wpbc_get_general_availability_url( true, false ) : admin_url( 'admin.php?page=wpbc-availability&tab=general_availability' ) // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
417 447 , 'position' => '' // 'left' || 'right' || ''
418 448 , 'css_classes' => 'wpbc_top_tab__general_availability' // CSS class(es)
419 449 , 'icon' => '' // Icon - link to the real PNG img
420 450 , 'font_icon' => 'wpbc-bi-calendar2-day 0wpbc-bi-calendar2-check'//'wpbc_icn_free_cancellation' // CSS definition of forn Icon
451 + , 'font_icon_right' => 'wpbc-bi-question-circle'
421 452 , 'default' => false // Is this tab activated by default or not: true || false.
422 453 , 'disabled' => false // Is this tab disbaled: true || false.
423 454 , 'hided' => false // Is this tab hided: true || false.
424 455 , 'subtabs' => array()
456 + // , 'folder_style' => 'order:200;',
457 + , 'folder_style' => 'order:93;',
425 458 );
426 459 // $subtabs = array();
427 460 // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
428 461 return $tabs;