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/_capacity/calendar_load.php +212 -35 10.15.611.8.4 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @file: wp-content/plugins/booking/includes/_capacity/calendar_load.php
4 4 */
@@ -22,8 +22,14 @@
22 22 $start_script_code .= " _wpbc.balancer__set_max_threads( " . $balancer_max_threads . " ); ";
23 23
24 24 $resource_id = isset( $params['resource_id'] ) ? absint( $params['resource_id'] ) : 1;
25 25
26 + if ( function_exists( 'wpbc_is_booking_used_check_in_out_time' ) ) {
27 + $is_enabled_change_over = wpbc_is_booking_used_check_in_out_time( false, $resource_id );
28 + $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . " , 'is_enabled_change_over' , " . ( $is_enabled_change_over ? 'true' : 'false' ) . " ); ";
29 + $start_script_code .= " _wpbc.set_other_param( 'is_enabled_change_over', " . ( $is_enabled_change_over ? 'true' : 'false' ) . " ); ";
30 + }
31 +
26 32 // Start Month (require [year,month]).
27 33 $calendar_scroll_to = 'false';
28 34 if (
29 35 isset( $params['start_month_calendar'] )
@@ -38,13 +44,15 @@
38 44 }
39 45 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . " , 'calendar_scroll_to' , " . $calendar_scroll_to . " ); ";
40 46
41 47 // Set Start / End Date in Calendar (JSON encode => safe quotes).
42 - $params['calendar_dates_start'] = ( empty( $params['calendar_dates_start'] ) ) ? '' : (string) $params['calendar_dates_start'];
43 - $params['calendar_dates_end'] = ( empty( $params['calendar_dates_end'] ) ) ? '' : (string) $params['calendar_dates_end'];
48 + $params['calendar_dates_start'] = ( empty( $params['calendar_dates_start'] ) ) ? '' : (string) $params['calendar_dates_start'];
49 + $params['calendar_dates_end'] = ( empty( $params['calendar_dates_end'] ) ) ? '' : (string) $params['calendar_dates_end'];
50 + $params['classic_booking_context_token'] = empty( $params['classic_booking_context_token'] ) ? '' : (string) $params['classic_booking_context_token'];
44 51
45 52 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . " , 'calendar_dates_start' , " . wp_json_encode( $params['calendar_dates_start'] ) . " ); ";
46 - $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . " , 'calendar_dates_end' , " . wp_json_encode( $params['calendar_dates_end'] ) . " ); ";
53 + $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . " , 'calendar_dates_end' , " . wp_json_encode( $params['calendar_dates_end'] ) . " ); ";
54 + $start_script_code .= " _wpbc.booking__set_param_value( " . $resource_id . " , 'classic_booking_context_token' , " . wp_json_encode( $params['classic_booking_context_token'] ) . " ); ";
47 55
48 56 if ( ( '' !== $params['calendar_dates_start'] ) || ( '' !== $params['calendar_dates_end'] ) ) {
49 57 $start_script_code .= wpbc_get_localized_js__time_local( $params['calendar_dates_start'] );
50 58 }
@@ -60,9 +68,9 @@
60 68 $months_num = max( 1, min( 36, $months_num ) );
61 69 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . " , 'calendar_number_of_months' , " . wp_json_encode( (string) $months_num ) . " ); ";
62 70
63 71 // Days Selection.
64 - $days_selection_arr = wpbc__calendar__js_params__get_days_selection_arr();
72 + $days_selection_arr = wpbc__calendar__js_params__get_days_selection_arr();
65 73
66 74 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'days_select_mode', " . wp_json_encode( (string) $days_selection_arr['days_select_mode'] ) . " ); ";
67 75 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'fixed__days_num', " . intval( $days_selection_arr['fixed__days_num'] ) . " ); ";
68 76
@@ -69,12 +77,32 @@
69 77 // Keep legacy: these are stored as comma lists like "-1" or "0,1".
70 78 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'fixed__week_days__start', [" . $days_selection_arr['fixed__week_days__start'] . "] ); ";
71 79 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'dynamic__days_min', " . intval( $days_selection_arr['dynamic__days_min'] ) . " ); ";
72 80 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'dynamic__days_max', " . intval( $days_selection_arr['dynamic__days_max'] ) . " ); ";
73 - $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'dynamic__days_specific', [" . $days_selection_arr['dynamic__days_specific'] . "] ); ";
74 - $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'dynamic__week_days__start', [" . $days_selection_arr['dynamic__week_days__start'] . "] ); ";
75 -
76 - // Date / Time formats.
81 + $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'dynamic__days_specific', [" . $days_selection_arr['dynamic__days_specific'] . "] ); ";
82 + $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'dynamic__week_days__start', [" . $days_selection_arr['dynamic__week_days__start'] . "] ); ";
83 +
84 + // Informational help shown between the first and second clicks in range mode.
85 + // Integrations can disable it per calendar/resource without changing the selection engine.
86 + /**
87 + * Filters whether the two-click range-selection guidance is shown for a calendar.
88 + *
89 + * @param bool $is_enabled Whether guidance is enabled.
90 + * @param int $resource_id Booking resource ID.
91 + * @param array $params Calendar shortcode/render parameters.
92 + */
93 + $range_selection_guidance_default = function_exists( 'wpbc_frontend_messages__is_enabled' )
94 + ? wpbc_frontend_messages__is_enabled( 'message_range_selection_click_last_date' )
95 + : true;
96 + $range_selection_guidance_is_enabled = (bool) apply_filters(
97 + 'wpbc_calendar_range_selection_guidance_is_enabled',
98 + $range_selection_guidance_default,
99 + $resource_id,
100 + $params
101 + );
102 + $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'range_selection_guidance_is_enabled', " . ( $range_selection_guidance_is_enabled ? 'true' : 'false' ) . " ); ";
103 +
104 + // Date / Time formats.
77 105 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'booking_date_format', " . wp_json_encode( (string) get_bk_option( 'booking_date_format' ) ) . " ); ";
78 106 $start_script_code .= " _wpbc.calendar__set_param_value( " . $resource_id . ", 'booking_time_format', " . wp_json_encode( (string) get_bk_option( 'booking_time_format' ) ) . " ); ";
79 107
80 108 // Capacity | availability.
@@ -108,21 +136,28 @@
108 136
109 137 /**
110 138 * Get days selection parameters, which saved in database
111 139 *
112 - * @return array
113 - */
114 - function wpbc__calendar__js_params__get_days_selection_arr(){
140 + * @return array
141 + */
142 + function wpbc__calendar__js_params__get_days_selection_arr(){
115 143
116 144 $specific_days_selection = ( function_exists( 'wpbc_get_specific_range_dates__as_comma_list' ) )
117 145 ? wpbc_get_specific_range_dates__as_comma_list( get_bk_option( 'booking_range_selection_days_specific_num_dynamic' ) )
118 146 : '';
119 - $data_arr = array();
120 - // Modes :: Selection of Days
121 - $data_arr['days_select_mode'] = ( 'range' === get_bk_option('booking_type_of_day_selections') )
122 - ? get_bk_option('booking_range_selection_type')
123 - : get_bk_option( 'booking_type_of_day_selections');
124 - $data_arr['fixed__days_num'] = intval( get_bk_option( 'booking_range_selection_days_count' ) ); /* Number of days selection with 1 mouse click */
147 + $data_arr = array();
148 + // Modes :: Selection of Days.
149 + $day_selection_type = get_bk_option( 'booking_type_of_day_selections' );
150 + if ( 'range' === $day_selection_type ) {
151 + // Free/Personal use the unrestricted two-click range. Business Small+ can apply its saved range subtype/rules.
152 + $data_arr['days_select_mode'] = class_exists( 'wpdev_bk_biz_s' )
153 + ? get_bk_option( 'booking_range_selection_type' )
154 + : 'dynamic';
155 + } else {
156 + $data_arr['days_select_mode'] = $day_selection_type;
157 + }
158 + $fixed_days_num = absint( get_bk_option( 'booking_range_selection_days_count' ) );
159 + $data_arr['fixed__days_num'] = ( 0 < $fixed_days_num ) ? min( 180, $fixed_days_num ) : 3; /* Number of days selection with 1 mouse click */
125 160 $data_arr['fixed__week_days__start'] = get_bk_option( 'booking_range_start_day' ); /* { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat } */
126 161 $data_arr['dynamic__days_min'] = intval( get_bk_option( 'booking_range_selection_days_count_dynamic' ) ); /* Min. Number of days selection with 2 mouse clicks */
127 162 $data_arr['dynamic__days_max'] = intval( get_bk_option( 'booking_range_selection_days_max_count_dynamic' ) ); /* Max. Number of days selection with 2 mouse clicks */
128 163 $data_arr['dynamic__days_specific'] = $specific_days_selection; /* Example: '5,7' */
@@ -127,12 +162,15 @@
127 162 $data_arr['dynamic__days_max'] = intval( get_bk_option( 'booking_range_selection_days_max_count_dynamic' ) ); /* Max. Number of days selection with 2 mouse clicks */
128 163 $data_arr['dynamic__days_specific'] = $specific_days_selection; /* Example: '5,7' */
129 164 $data_arr['dynamic__week_days__start'] = get_bk_option( 'booking_range_start_day_dynamic' ); /* { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat } */
130 165
131 - // Fix about possible issue of downgrade from Paid to free version and try to use 'Range days' selection, which is not supports in that version. // FixIn: 10.4.0.4.
132 - if ( ( ! class_exists( 'wpdev_bk_biz_s' ) ) && ( in_array( $data_arr['days_select_mode'], array( 'dynamic', 'fixed' ) ) ) ) {
133 - $data_arr['days_select_mode'] = 'multiple';
134 - }
166 + // A fixed one-click range remains Business Small+. On downgrade, preserve the Range choice but use Free's unrestricted two-click mode.
167 + if ( ( ! class_exists( 'wpdev_bk_biz_s' ) ) && ( in_array( $data_arr['days_select_mode'], array( 'dynamic', 'fixed' ), true ) ) ) {
168 + $data_arr['days_select_mode'] = 'dynamic';
169 + $data_arr['dynamic__days_min'] = 1;
170 + $data_arr['dynamic__days_specific'] = '';
171 + $data_arr['dynamic__week_days__start'] = '-1';
172 + }
135 173
136 174 return $data_arr;
137 175 }
138 176
@@ -157,10 +195,13 @@
157 195 'start_month_calendar' => false,
158 196 'shortcode_options' => '',
159 197 'custom_form' => 'standard',
160 198 'calendar_dates_start' => '',
161 - 'calendar_dates_end' => '',
162 - );
199 + 'calendar_dates_end' => '',
200 + 'classic_booking_context_token' => '',
201 + 'skip_general_availability' => 0,
202 + 'calendar_request_overrides' => array(),
203 + );
163 204 $params = wp_parse_args( $params, $defaults );
164 205
165 206 // Resource ID.
166 207 $params['resource_id'] = absint( $params['resource_id'] );
@@ -215,10 +256,22 @@
215 256 'request_uri' => $server_request_uri,
216 257 'custom_form' => (string) $params['custom_form'],
217 258 'aggregate_resource_id_str' => implode( ',', (array) $params['aggregate_resource_id_arr'] ),
218 259 'aggregate_type' => (string) $aggregate_type,
260 + 'skip_general_availability' => (int) $params['skip_general_availability'],
261 + 'classic_booking_context_token' => (string) $params['classic_booking_context_token'],
219 262 );
220 263
264 + if ( ! empty( $params['calendar_request_overrides'] ) && is_array( $params['calendar_request_overrides'] ) ) {
265 + foreach ( $params['calendar_request_overrides'] as $override_key => $override_value ) {
266 + if ( 'allow_past' === $override_key ) {
267 + $params_for_request['allow_past'] = ! empty( $override_value ) ? 1 : 0;
268 + } elseif ( 0 === strpos( (string) $override_key, 'wpbc_settings_calendar_preview' ) ) {
269 + $params_for_request[ $override_key ] = $override_value;
270 + }
271 + }
272 + }
273 +
221 274 // Send Ajax request to load bookings.
222 275 $js_body .= " wpbc_calendar__load_data__ajx(" . wp_json_encode( $params_for_request ) . "); ";
223 276
224 277 // ---------------------------------------------------------------------
@@ -249,9 +302,34 @@
249 302 return $start_script_code;
250 303 }
251 304
252 305
306 +/**
307 + * Get Booking Calendar option names that belong to General Availability rules.
308 + *
309 + * @return array
310 + */
311 +function wpbc__calendar__get_general_availability_option_names() {
253 312
313 + $option_names = array(
314 + 'booking_unavailable_days_num_from_today',
315 + 'booking_available_days_num_from_today',
316 + 'booking_unavailable_extra_in_out',
317 + 'booking_unavailable_extra_minutes_in',
318 + 'booking_unavailable_extra_minutes_out',
319 + 'booking_unavailable_extra_days_in',
320 + 'booking_unavailable_extra_days_out',
321 + );
322 +
323 + foreach ( range( 0, 6 ) as $week_day_num ) {
324 + $option_names[] = 'booking_unavailable_day' . $week_day_num;
325 + }
326 +
327 + return $option_names;
328 +}
329 +
330 +
331 +
254 332 /**
255 333 * Response to Ajax request, about loading calendar data
256 334 *
257 335 * @return void
@@ -283,20 +361,91 @@
283 361 'user_id' => $user_id,
284 362 'request_rules_structure' => array(
285 363 'resource_id' => array( 'validate' => 'd', 'default' => 1 ), // 'digit_or_csd'
286 364 'booking_hash' => array( 'validate' => 's', 'default' => '' ),
287 - 'request_uri' => array( 'validate' => 's', 'default' => '' ),
288 - 'custom_form' => array( 'validate' => 's', 'default' => 'standard' ),
365 + 'request_uri' => array( 'validate' => 's', 'default' => '' ),
366 + 'custom_form' => array( 'validate' => 's', 'default' => 'standard' ),
367 + 'allow_past' => array( 'validate' => 'd', 'default' => 0 ),
368 + 'classic_booking_context_token' => array( 'validate' => 'strong', 'default' => '' ),
289 369 'aggregate_resource_id_str' => array( 'validate' => 'digit_or_csd', 'default' => '' ), // Comma separated string of resource ID, which was used in 'aggregate' parameter.
290 370 'aggregate_type' => array( 'validate' => 's', 'default' => 'all' ), // 'all' | 'bookings_only' // FixIn: 9.8.15.10.
291 371 'dates_to_check' => array( 'validate' => 'array', 'default' => '' ), // 'all' | 'bookings_only' // FixIn: 9.8.15.10.
372 + 'skip_general_availability' => array( 'validate' => 'd', 'default' => 0 ),
373 + 'wpbc_settings_calendar_preview' => array( 'validate' => 'd', 'default' => 0 ),
374 + 'wpbc_settings_calendar_preview_changeover' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
375 + 'wpbc_settings_calendar_preview_triangles' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'On' ),
376 + 'wpbc_settings_calendar_preview_recurrent_time' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
377 + 'wpbc_settings_calendar_preview_last_checkout' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
378 + 'wpbc_settings_calendar_preview_excerpt_on_pages' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
379 + 'wpbc_settings_calendar_preview_excerpt_pages' => array( 'validate' => 's', 'default' => '' ),
380 + 'wpbc_settings_calendar_preview_excerpt_resources' => array( 'validate' => 's', 'default' => '' ),
381 + 'wpbc_settings_calendar_preview_show_legend' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
382 + 'wpbc_settings_calendar_preview_legend_show_numbers' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
383 + 'wpbc_settings_calendar_preview_legend_vertical' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
384 + 'wpbc_settings_calendar_preview_legend_show_available' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
385 + 'wpbc_settings_calendar_preview_legend_text_available' => array( 'validate' => 's', 'default' => '' ),
386 + 'wpbc_settings_calendar_preview_legend_show_pending' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
387 + 'wpbc_settings_calendar_preview_legend_text_pending' => array( 'validate' => 's', 'default' => '' ),
388 + 'wpbc_settings_calendar_preview_legend_show_approved' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
389 + 'wpbc_settings_calendar_preview_legend_text_approved' => array( 'validate' => 's', 'default' => '' ),
390 + 'wpbc_settings_calendar_preview_legend_show_partially' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
391 + 'wpbc_settings_calendar_preview_legend_text_partially' => array( 'validate' => 's', 'default' => '' ),
392 + 'wpbc_settings_calendar_preview_legend_show_unavailable' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
393 + 'wpbc_settings_calendar_preview_legend_text_unavailable' => array( 'validate' => 's', 'default' => '' ),
394 + 'wpbc_settings_calendar_preview_disable_timeslots_tooltip' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
395 + 'wpbc_settings_calendar_preview_timeslot_word' => array( 'validate' => 's', 'default' => '' ),
396 + 'wpbc_settings_calendar_preview_show_availability_tooltip' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
397 + 'wpbc_settings_calendar_preview_availability_word' => array( 'validate' => 's', 'default' => '' ),
398 + 'wpbc_settings_calendar_preview_show_availability_cell' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
399 + 'wpbc_settings_calendar_preview_availability_cell_word' => array( 'validate' => 's', 'default' => '' ),
400 + 'wpbc_settings_calendar_preview_show_cost_tooltip' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
401 + 'wpbc_settings_calendar_preview_cost_word' => array( 'validate' => 's', 'default' => '' ),
402 + 'wpbc_settings_calendar_preview_show_cost_cell' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
403 + 'wpbc_settings_calendar_preview_cost_currency' => array( 'validate' => 's', 'default' => '' ),
404 + 'wpbc_settings_calendar_preview_show_booked_details' => array( 'validate' => array( 'On', 'Off' ), 'default' => 'Off' ),
405 + 'wpbc_settings_calendar_preview_booked_details' => array( 'validate' => 's', 'default' => '' ),
292 406 )
293 407 )
294 408 );
295 - $request_prefix = 'calendar_request_params';
296 - $request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // NOT Direct: $_REQUEST['search_params']['resource_id']
409 + $request_prefix = 'calendar_request_params';
410 + $request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // NOT Direct: $_REQUEST['search_params']['resource_id']
411 + if ( ! empty( $request_params['classic_booking_context_token'] ) && function_exists( 'wpbc_classic_booking_context_validate_submission' ) ) {
412 + $classic_context = wpbc_classic_booking_context_validate_submission(
413 + $request_params['classic_booking_context_token'],
414 + $request_params['resource_id'],
415 + $request_params['dates_to_check'],
416 + $request_params['custom_form'],
417 + $request_params['aggregate_resource_id_str']
418 + );
419 + if ( ! is_wp_error( $classic_context ) ) {
420 + $request_params['allow_past'] = ! empty( $classic_context['allow_past'] ) ? 1 : 0;
421 + // Use the signed canonical set so equivalent wire shapes cannot change availability input.
422 + $request_params['aggregate_resource_id_str'] = implode( ',', $classic_context['aggregate_resource_ids'] );
423 + $request_params['dates_to_check'] = array(
424 + $classic_context['calendar_dates_start'],
425 + $classic_context['calendar_dates_end'],
426 + );
427 + } else {
428 + $request_params['allow_past'] = 0;
429 + }
430 + }
431 + $can_allow_past = ! empty( $request_params['allow_past'] );
432 + $request_params['allow_past'] = $can_allow_past ? 1 : 0;
297 433
434 + if ( ! empty( $request_params['skip_general_availability'] ) ) {
435 + $can_skip_general_availability = (
436 + function_exists( 'wpbc_availability_general__get_manage_cap' )
437 + && function_exists( 'wpbc_is_mu_user_can_be_here' )
438 + && wpbc_is_mu_user_can_be_here( 'only_super_admin' )
439 + && current_user_can( wpbc_availability_general__get_manage_cap() )
440 + );
298 441
442 + if ( ! $can_skip_general_availability ) {
443 + $request_params['skip_general_availability'] = 0;
444 + }
445 + }
446 +
447 +
299 448 // Do Job here !! -------------------------------------------------------------------------------------------------
300 449
301 450 make_bk_action( 'check_pending_unpaid_bookings__do_auto_cancel', $request_params['resource_id'] );
302 451
@@ -310,16 +459,18 @@
310 459 unset( $aggregate_resource_id_arr[ $resource_id_key ] ); // Remove source booking resource from aggregate ARR. // FixIn: 9.8.15.10.
311 460 }
312 461 $aggregate_resource_id_arr = array_values($aggregate_resource_id_arr); // Reset keys
313 462
314 - $availability_per_days__params = array(
315 - 'resource_id' => $request_params['resource_id'],
316 - 'max_days_count' => $max_days_count,
317 - 'skip_booking_id' => $skip_booking_id,
318 - 'request_uri' => $request_params['request_uri'], // It different in Ajax requests than $server_request_uri . It's used for change-over days to detect for exception at specific pages
319 - 'custom_form' => $request_params['custom_form']
463 + $availability_per_days__params = array(
464 + 'resource_id' => $request_params['resource_id'],
465 + 'max_days_count' => $max_days_count,
466 + 'skip_booking_id' => $skip_booking_id,
467 + 'request_uri' => $request_params['request_uri'], // It different in Ajax requests than $server_request_uri . It's used for change-over days to detect for exception at specific pages
468 + 'custom_form' => $request_params['custom_form'],
469 + 'allow_past' => ! empty( $request_params['allow_past'] )
320 470 , 'additional_bk_types' => $aggregate_resource_id_arr // It is array of booking resources from aggregate parameter() // arrays | CSD | int // OPTIONAL
321 471 , 'aggregate_type' => $request_params['aggregate_type'] // It is string: 'all' | 'bookings_only' // OPTIONAL
472 + , 'skip_general_availability' => $request_params['skip_general_availability']
322 473 // , 'as_single_resource' => true // get dates as for 'single resource' or 'parent' resource including bookings in all 'child booking resources'
323 474 // , 'max_days_count' => wpbc_get_max_visible_days_in_calendar() // 365
324 475 // , 'timeslots_to_check_intersect' => $timeslots_to_check_intersect //TODO 2023-10-25: delete it, because we get it in wpbc_get_availability_per_days_arr() //array( '12:20 - 12:55', '13:00 - 14:00' )
325 476 );
@@ -327,9 +478,9 @@
327 478 if ( ! empty( $request_params['dates_to_check'] ) ) {
328 479 $availability_per_days__params['dates_to_check'] = $request_params['dates_to_check']; // Usually if defined it is: [ '2025-01-01', '2025-12-31' ], because of shortcode [booking resource_id=4 calendar_dates_start='2025-01-01' calendar_dates_end='2025-12-31' ...]
329 480 }
330 481
331 - // If in Booking > Add booking page we use in URL .../wp-admin/admin.php?page=wpbc-new&booking_type=2&as_single_resource=1 then get availability only for single resource.
482 + // If in Booking > Add booking page we use in URL .../wp-admin/admin.php?page=wpbc&tab=add-booking&booking_type=2&as_single_resource=1 then get availability only for single resource.
332 483 if (
333 484 ( ! empty( $request_params['request_uri'] ) )
334 485 && ( strpos( $request_params['request_uri'], 'as_single_resource=1' ) !== false )
335 486 ){
@@ -337,9 +488,9 @@
337 488 }
338 489
339 490 /**
340 491 * Tricks:
341 - * if ( strpos( $request_params['request_uri'],'page=wpbc-new' ) !== false ) { $availability_per_days__params['is_days_always_available'] = true; }
492 + * if ( wpbc_is_new_booking_page_url( $request_params['request_uri'] ) ) { $availability_per_days__params['is_days_always_available'] = true; }
342 493 *
343 494 * // Set dates in calendar always available only for specific resources with specific ID
344 495 * if ( in_array( $request_params['resource_id'], array( 12, 15, 17 ) ) ) { $availability_per_days__params['is_days_always_available'] = true; }
345 496 */
@@ -345,9 +496,35 @@
345 496 */
346 497
347 498 // Get unavailable dates for calendar
348 499 // $availability_per_days__params['dates_to_check'] = array( '2025-01-01', '2025-12-31' ); // FixIn: 10.13.1.4.
500 + global $wpbc__skip_get_bk_options;
501 +
502 + $previous_skip_get_bk_options = $wpbc__skip_get_bk_options;
503 + $previous_settings_calendar_preview_options = null;
504 + $is_settings_calendar_preview = (
505 + function_exists( 'wpbc_settings_calendar__is_calendar_load_preview_request_allowed' )
506 + && wpbc_settings_calendar__is_calendar_load_preview_request_allowed( $request_params )
507 + );
508 + if ( ! empty( $availability_per_days__params['skip_general_availability'] ) ) {
509 + $wpbc__skip_get_bk_options = array_unique(
510 + array_merge(
511 + (array) $wpbc__skip_get_bk_options,
512 + wpbc__calendar__get_general_availability_option_names()
513 + )
514 + );
515 + }
516 + if ( $is_settings_calendar_preview ) {
517 + $previous_settings_calendar_preview_options = wpbc_settings_calendar__preview_options_push(
518 + wpbc_settings_calendar__get_calendar_load_preview_options( $request_params )
519 + );
520 + }
521 +
349 522 $availability_per_days_arr = wpbc_get_availability_per_days_arr( $availability_per_days__params );
523 + $wpbc__skip_get_bk_options = $previous_skip_get_bk_options;
524 + if ( $is_settings_calendar_preview ) {
525 + wpbc_settings_calendar__preview_options_pop( $previous_settings_calendar_preview_options );
526 + }
350 527
351 528
352 529 $ajx_data_arr = array( /**
353 530 * Send JSON. It will make "wp_json_encode" - so pass only array, and This function call wp_die( '', '', array( 'response' => null, ) ) .