PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 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 All 205 releases
booking / includes / page-setup-wizard / step-date-selection / template.php

template.php in Booking Calendar 11.9, at includes/page-setup-wizard/step-date-selection/template.php

566 lines 41.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Setup Wizard Date Selection editor.
4 *
5 * @package Booking Calendar
6 * @var array<string,mixed> $template_context Authorized step context.
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 $step_data = isset( $template_context['step_data'] ) && is_array( $template_context['step_data'] ) ? $template_context['step_data'] : array();
14 $values = isset( $step_data['values'] ) && is_array( $step_data['values'] ) ? $step_data['values'] : array();
15 $weekdays = isset( $step_data['weekdays'] ) && is_array( $step_data['weekdays'] ) ? $step_data['weekdays'] : array();
16 $specific_day_presets = isset( $step_data['specific_day_presets'] ) && is_array( $step_data['specific_day_presets'] ) ? $step_data['specific_day_presets'] : array();
17 $legend_items = isset( $step_data['legend_items'] ) && is_array( $step_data['legend_items'] ) ? $step_data['legend_items'] : array();
18 $legend_preview_items = isset( $step_data['legend_preview_items'] ) && is_array( $step_data['legend_preview_items'] ) ? $step_data['legend_preview_items'] : array();
19 $time_options = isset( $step_data['time_options'] ) && is_array( $step_data['time_options'] ) ? $step_data['time_options'] : array();
20 $supports_advanced = ! empty( $step_data['supports_advanced_range_rules'] );
21 $preview_html = isset( $step_data['preview_html'] ) && is_string( $step_data['preview_html'] ) ? $step_data['preview_html'] : '';
22 $preview_error = isset( $step_data['preview_error'] ) && is_string( $step_data['preview_error'] ) ? $step_data['preview_error'] : '';
23 $resource_id = isset( $step_data['preview_resource_id'] ) ? absint( $step_data['preview_resource_id'] ) : 1;
24 $customer_journey_policy = isset( $step_data['customer_journey_policy'] ) && is_array( $step_data['customer_journey_policy'] ) ? $step_data['customer_journey_policy'] : array();
25 $journey_mode_policies = isset( $customer_journey_policy['mode_policy'] ) && is_array( $customer_journey_policy['mode_policy'] ) ? $customer_journey_policy['mode_policy'] : array();
26 $selected_mode = isset( $values['date_selection_mode'] ) ? (string) $values['date_selection_mode'] : 'single';
27 $selected_mode_policy = isset( $journey_mode_policies[ $selected_mode ] ) && is_array( $journey_mode_policies[ $selected_mode ] ) ? $journey_mode_policies[ $selected_mode ] : array();
28 $changeover_policy = isset( $selected_mode_policy['changeover'] ) ? (string) $selected_mode_policy['changeover'] : 'hidden_off';
29 $recurrent_policy = isset( $selected_mode_policy['recurrent_time'] ) ? (string) $selected_mode_policy['recurrent_time'] : 'hidden_off';
30 $checkout_policy = isset( $selected_mode_policy['checkout_available'] ) ? (string) $selected_mode_policy['checkout_available'] : 'hidden_off';
31 $calendar_preview_year = absint( current_time( 'Y' ) );
32 $dynamic_weekdays = isset( $values['date_selection_dynamic_weekdays'] ) ? explode( ',', (string) $values['date_selection_dynamic_weekdays'] ) : array( '-1' );
33 $fixed_weekdays = isset( $values['date_selection_fixed_weekdays'] ) ? explode( ',', (string) $values['date_selection_fixed_weekdays'] ) : array( '-1' );
34 $changeover_is_enabled = $supports_advanced && isset( $values['date_selection_changeover_enabled'] ) && 'On' === $values['date_selection_changeover_enabled'];
35 $changeover_is_visible = in_array( $changeover_policy, array( 'optional', 'required_on' ), true );
36 $recurrent_is_visible = in_array( $recurrent_policy, array( 'optional', 'optional_default_on', 'required_on' ), true );
37 $checkout_is_supported = 'optional' === $checkout_policy;
38 $behavior_is_visible = $recurrent_is_visible || $checkout_is_supported;
39 $locked_mode_count = 0;
40 $legend_is_enabled = isset( $values['date_selection_legend_enabled'] ) && 'On' === $values['date_selection_legend_enabled'];
41 $legend_is_vertical = isset( $values['date_selection_legend_vertical'] ) && 'On' === $values['date_selection_legend_vertical'];
42 $advanced_toggle_disabled_reason = __( 'This option requires Booking Calendar Business Small or higher.', 'booking' );
43 $checkout_changeover_disabled_reason = __( 'Turn off Changeover days to use this option. Changeover processing already controls the check-out boundary.', 'booking' );
44 $checkout_mode_disabled_reason = __( 'This option is available only for Flexible or Fixed range selection.', 'booking' );
45 $changeover_journey_disabled_reason = __( 'Changeover days are required by the selected Customer Journey.', 'booking' );
46 $recurrent_journey_disabled_reason = __( 'The selected Customer Journey requires the same selected times on every booking date.', 'booking' );
47 $checkout_disabled_reason = '';
48
49 if ( ! $supports_advanced ) {
50 $checkout_disabled_reason = $advanced_toggle_disabled_reason;
51 } elseif ( ! $checkout_is_supported ) {
52 $checkout_disabled_reason = $checkout_mode_disabled_reason;
53 } elseif ( $changeover_is_enabled ) {
54 $checkout_disabled_reason = $checkout_changeover_disabled_reason;
55 }
56
57 if ( in_array( '-1', $dynamic_weekdays, true ) ) {
58 $dynamic_weekdays = array_column( $weekdays, 'value' );
59 }
60 if ( in_array( '-1', $fixed_weekdays, true ) ) {
61 $fixed_weekdays = array_column( $weekdays, 'value' );
62 }
63 foreach ( $journey_mode_policies as $journey_mode_policy ) {
64 if ( isset( $journey_mode_policy['status'] ) && 'locked' === $journey_mode_policy['status'] ) {
65 $locked_mode_count++;
66 }
67 }
68
69 $selection_modes = array(
70 'single' => array(
71 'label' => __( 'Single day', 'booking' ),
72 'description' => __( 'Customers choose one date.', 'booking' ),
73 'calendar_preview_type' => 'calendar',
74 ),
75 'multiple' => array(
76 'label' => __( 'Multiple days', 'booking' ),
77 'description' => __( 'Customers choose independent dates.', 'booking' ),
78 'calendar_preview_type' => 'calendar-multiple',
79 ),
80 'dynamic' => array(
81 'label' => __( 'Flexible range', 'booking' ),
82 'description' => __( 'Customers choose the first and last date.', 'booking' ),
83 'calendar_preview_type' => 'range-flexible-end',
84 ),
85 'fixed' => array(
86 'label' => __( 'Fixed range', 'booking' ),
87 'description' => __( 'One click selects a set number of days.', 'booking' ),
88 'calendar_preview_type' => 'range-fixed-selected',
89 ),
90 );
91 ?>
92 <section class="wpbc_setup_wizard__step-content wpbc_setup_wizard__date-selection-step" aria-labelledby="wpbc-setup-wizard-step-title" data-wpbc-date-selection-editor data-resource-id="<?php echo esc_attr( (string) $resource_id ); ?>">
93 <header class="wpbc_setup_wizard__step-heading">
94 <h1 id="wpbc-setup-wizard-step-title"><?php esc_html_e( 'Choose how dates are selected', 'booking' ); ?></h1>
95 <p class="wpbc_setup_wizard__lead"><?php esc_html_e( 'Select one behavior and check the customer preview.', 'booking' ); ?></p>
96 </header>
97 <?php
98 $template_context['templates']->render(
99 'settings-hint',
100 array( 'settings_hint' => $template_context['settings_hint'] )
101 );
102 ?>
103
104 <form id="wpbc-setup-wizard-step-form" class="wpbc_setup_wizard__date-selection-form" novalidate>
105 <fieldset class="wpbc_setup_wizard__date-selection-modes" data-wpbc-date-selection-modes>
106 <div class="wpbc_setup_wizard__date-selection-modes-heading">
107 <strong><?php esc_html_e( 'Selection mode', 'booking' ); ?></strong>
108 <span class="wpbc_setup_wizard__date-selection-compatibility-note">
109 <i class="menu_icon icon-1x wpbc_icn_info_outline" aria-hidden="true"></i>
110 <?php esc_html_e( 'Only compatible date behaviors can be selected.', 'booking' ); ?>
111 </span>
112 <?php if ( ! empty( $customer_journey_policy['label'] ) ) : ?>
113 <span class="wpbc_setup_wizard__date-selection-journey-badge">
114 <?php
115 echo esc_html(
116 sprintf(
117 /* translators: %s: Selected Customer Journey name. */
118 __( 'Journey: %s', 'booking' ),
119 (string) $customer_journey_policy['label']
120 )
121 );
122 ?>
123 </span>
124 <?php endif; ?>
125 </div>
126 <div class="wpbc_setup_wizard__date-selection-mode-grid">
127 <?php foreach ( $selection_modes as $mode_id => $mode ) : ?>
128 <?php
129 $mode_policy = isset( $journey_mode_policies[ $mode_id ] ) && is_array( $journey_mode_policies[ $mode_id ] ) ? $journey_mode_policies[ $mode_id ] : array();
130 $mode_status = isset( $mode_policy['status'] ) ? (string) $mode_policy['status'] : 'locked';
131 $is_policy_locked = 'locked' === $mode_status;
132 $is_edition_locked = 'fixed' === $mode_id && ! $supports_advanced;
133 $is_locked = $is_policy_locked || $is_edition_locked;
134 $disabled_reason = $is_edition_locked ? $advanced_toggle_disabled_reason : ( isset( $mode_policy['disabled_reason'] ) ? (string) $mode_policy['disabled_reason'] : '' );
135 $badge_label = isset( $mode_policy['badge_label'] ) ? (string) $mode_policy['badge_label'] : '';
136 ?>
137 <div class="wpbc_setup_wizard__date-selection-mode-option">
138 <?php if ( '' !== $badge_label || $is_edition_locked ) : ?>
139 <span class="wpbc_setup_wizard__date-selection-mode-badges">
140 <?php if ( '' !== $badge_label ) : ?>
141 <span class="wpbc_setup_wizard__date-selection-mode-badge is-<?php echo esc_attr( $mode_status ); ?>"><?php echo esc_html( $badge_label ); ?></span>
142 <?php endif; ?>
143 <?php if ( $is_edition_locked ) : ?>
144 <span class="wpbc_setup_wizard__edition-badge"><?php esc_html_e( 'PRO / BS+', 'booking' ); ?></span>
145 <?php endif; ?>
146 </span>
147 <?php endif; ?>
148 <label
149 class="wpbc_setup_wizard__date-selection-mode-card is-<?php echo esc_attr( $mode_status ); ?><?php echo $selected_mode === $mode_id ? ' is-selected' : ''; ?><?php echo $is_locked ? ' is-locked' : ''; ?>"
150 <?php if ( $is_locked ) : ?>
151 aria-disabled="true"
152 title="<?php echo esc_attr( $disabled_reason ); ?>"
153 <?php endif; ?>
154 >
155 <input
156 type="radio"
157 name="date_selection_mode"
158 value="<?php echo esc_attr( $mode_id ); ?>"
159 data-wpbc-setup-wizard-field
160 data-wpbc-date-selection-mode
161 data-wpbc-date-selection-mode-status="<?php echo esc_attr( $mode_status ); ?>"
162 data-wpbc-date-selection-policy-changeover="<?php echo esc_attr( isset( $mode_policy['changeover'] ) ? (string) $mode_policy['changeover'] : 'hidden_off' ); ?>"
163 data-wpbc-date-selection-policy-recurrent-time="<?php echo esc_attr( isset( $mode_policy['recurrent_time'] ) ? (string) $mode_policy['recurrent_time'] : 'hidden_off' ); ?>"
164 data-wpbc-date-selection-policy-checkout-available="<?php echo esc_attr( isset( $mode_policy['checkout_available'] ) ? (string) $mode_policy['checkout_available'] : 'hidden_off' ); ?>"
165 required
166 <?php checked( $selected_mode, $mode_id ); ?>
167 <?php disabled( $is_locked ); ?>
168 >
169 <span class="wpbc_setup_wizard__date-selection-mode-icon wpbc_setup_wizard__journey-step--<?php echo esc_attr( $mode['calendar_preview_type'] ); ?>" aria-hidden="true">
170 <span class="wpbc_setup_wizard__date-selection-mode-header">
171 <strong class="wpbc_setup_wizard__date-selection-mode-year"><?php echo esc_html( (string) $calendar_preview_year ); ?></strong>
172 <span class="wpbc_setup_wizard__date-selection-mode-navigation">
173 <i class="menu_icon icon-1x wpbc_icn_keyboard_arrow_left" aria-hidden="true"></i>
174 <i class="menu_icon icon-1x wpbc_icn_keyboard_arrow_right" aria-hidden="true"></i>
175 </span>
176 </span>
177 <span class="wpbc_setup_wizard__preview-calendar">
178 <?php for ( $calendar_index = 0; $calendar_index < 28; $calendar_index++ ) : ?>
179 <span></span>
180 <?php endfor; ?>
181 </span>
182 </span>
183 <span class="wpbc_setup_wizard__date-selection-mode-copy">
184 <strong>
185 <?php echo esc_html( $mode['label'] ); ?>
186 <?php if ( $is_policy_locked ) : ?>
187 <i class="menu_icon icon-1x wpbc_icn_lock_outline" aria-hidden="true"></i>
188 <?php endif; ?>
189 </strong>
190 <small><?php echo esc_html( $mode['description'] ); ?></small>
191 </span>
192 </label>
193 </div>
194 <?php endforeach; ?>
195 </div>
196 <?php if ( 0 < $locked_mode_count ) : ?>
197 <button type="button" class="button-link wpbc_setup_wizard__date-selection-review-journeys" data-wpbc-setup-wizard-direction="back"><?php esc_html_e( 'Review Customer Journey options', 'booking' ); ?></button>
198 <?php endif; ?>
199 <span class="wpbc_setup_wizard__field-error wpbc_setup_wizard__field-error--group" data-wpbc-setup-wizard-error-for="date_selection_mode"></span>
200 </fieldset>
201
202 <div class="wpbc_setup_wizard__date-selection-workspace">
203 <section class="wpbc_setup_wizard__date-selection-preview" aria-labelledby="wpbc-date-selection-preview-title">
204 <h2 id="wpbc-date-selection-preview-title"><?php esc_html_e( 'Customer preview', 'booking' ); ?></h2>
205 <p class="wpbc_setup_wizard__date-selection-preview-help"><?php esc_html_e( 'Try selecting dates. This uses the real Booking Calendar selection behavior and your current availability.', 'booking' ); ?></p>
206 <div class="wpbc_setup_wizard__date-selection-calendar" data-wpbc-date-selection-calendar>
207 <?php if ( '' !== $preview_html ) : ?>
208 <?php echo $preview_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Generated by the canonical Booking Calendar renderer. ?>
209 <?php else : ?>
210 <div class="notice notice-warning inline wpbc_setup_wizard__message wpbc_setup_wizard__message--warning"><p><?php echo esc_html( $preview_error ); ?></p></div>
211 <?php endif; ?>
212 </div>
213 <div class="wpbc_setup_wizard__date-selection-legend-preview<?php echo $legend_is_vertical ? ' is-vertical' : ''; ?>" data-wpbc-date-selection-legend-preview data-wpbc-date-selection-legend-day-number="<?php echo esc_attr( wp_date( 'd' ) ); ?>"<?php if ( ! $legend_is_enabled ) : ?> hidden<?php endif; ?>>
214 <?php foreach ( $legend_items as $legend_item ) : ?>
215 <?php
216 $legend_id = (string) $legend_item['id'];
217 $legend_item_key = 'date_selection_legend_item_' . $legend_id;
218 ?>
219 <div data-wpbc-date-selection-legend-preview-item="<?php echo esc_attr( $legend_id ); ?>"<?php if ( ! isset( $values[ $legend_item_key ] ) || 'On' !== $values[ $legend_item_key ] ) : ?> hidden<?php endif; ?>>
220 <?php if ( ! empty( $legend_preview_items[ $legend_id ] ) ) : ?>
221 <?php echo $legend_preview_items[ $legend_id ]; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Generated by the canonical Booking Calendar legend renderer. ?>
222 <?php endif; ?>
223 </div>
224 <?php endforeach; ?>
225 </div>
226 </section>
227
228 <div class="wpbc_setup_wizard__date-selection-sidebar">
229 <aside class="wpbc_setup_wizard__date-selection-settings" aria-labelledby="wpbc-date-selection-settings-title">
230 <div class="wpbc_setup_wizard__date-selection-settings-heading">
231 <h2 id="wpbc-date-selection-settings-title" data-wpbc-date-selection-settings-title><?php esc_html_e( 'Date selection settings', 'booking' ); ?></h2>
232 <?php if ( ! $supports_advanced ) : ?>
233 <span class="wpbc_setup_wizard__edition-badge"><?php esc_html_e( 'PRO / BS+', 'booking' ); ?></span>
234 <?php endif; ?>
235 </div>
236
237 <div class="wpbc_setup_wizard__date-selection-settings-panel" data-wpbc-date-selection-panel="single">
238 <p><?php esc_html_e( 'Each click replaces the previous date selection with one date.', 'booking' ); ?></p>
239 </div>
240
241 <div class="wpbc_setup_wizard__date-selection-settings-panel" data-wpbc-date-selection-panel="multiple">
242 <p><?php esc_html_e( 'Each click adds or removes an independent date from the selection.', 'booking' ); ?></p>
243 </div>
244
245 <div class="wpbc_setup_wizard__date-selection-settings-panel" data-wpbc-date-selection-panel="fixed">
246 <div class="wpbc_setup_wizard__date-selection-number-field">
247 <div class="wpbc_setup_wizard__date-selection-number-heading">
248 <label for="wpbc-date-selection-fixed-days"><?php esc_html_e( 'Number of days', 'booking' ); ?></label>
249 <input id="wpbc-date-selection-fixed-days" type="number" name="date_selection_fixed_days" min="1" max="365" step="1" value="<?php echo esc_attr( $values['date_selection_fixed_days'] ); ?>" data-wpbc-setup-wizard-field data-wpbc-date-selection-number="date_selection_fixed_days" required>
250 </div>
251 <input class="wpbc_setup_wizard__date-selection-range" type="range" min="1" max="180" step="1" value="<?php echo esc_attr( $values['date_selection_fixed_days'] ); ?>" data-wpbc-date-selection-range="date_selection_fixed_days" aria-label="<?php esc_attr_e( 'Number of days selected with one click', 'booking' ); ?>">
252 <p class="wpbc_setup_wizard__date-selection-number-help"><?php esc_html_e( 'One click selects this many consecutive days.', 'booking' ); ?></p>
253 </div>
254 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="date_selection_fixed_days"></span>
255 <?php
256 // The visible weekday buttons are synchronized into this allow-listed scalar transport field.
257 ?>
258 <input type="hidden" name="date_selection_fixed_weekdays" value="<?php echo esc_attr( $values['date_selection_fixed_weekdays'] ); ?>" data-wpbc-setup-wizard-field data-wpbc-date-selection-weekday-transport="fixed" required>
259 <div class="wpbc_setup_wizard__date-selection-weekdays" data-wpbc-date-selection-weekdays="fixed" role="group" aria-label="<?php esc_attr_e( 'Allowed fixed range start days', 'booking' ); ?>">
260 <span><?php esc_html_e( 'A booking can start on', 'booking' ); ?></span>
261 <div>
262 <?php foreach ( $weekdays as $weekday ) : ?>
263 <button type="button" class="button<?php echo in_array( (string) $weekday['value'], $fixed_weekdays, true ) ? ' is-selected' : ''; ?>" data-weekday="<?php echo esc_attr( (string) $weekday['value'] ); ?>" aria-pressed="<?php echo in_array( (string) $weekday['value'], $fixed_weekdays, true ) ? 'true' : 'false'; ?>" title="<?php echo esc_attr( (string) $weekday['label'] ); ?>"><?php echo esc_html( (string) $weekday['short_label'] ); ?></button>
264 <?php endforeach; ?>
265 </div>
266 </div>
267 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="date_selection_fixed_weekdays"></span>
268 </div>
269
270 <div class="wpbc_setup_wizard__date-selection-settings-panel" data-wpbc-date-selection-panel="dynamic">
271 <p class="wpbc_setup_wizard__date-selection-number-intro"><?php esc_html_e( 'Set the shortest and longest flexible range customers can select.', 'booking' ); ?></p>
272 <div class="wpbc_setup_wizard__date-selection-number-grid">
273 <div class="wpbc_setup_wizard__date-selection-number-field">
274 <div class="wpbc_setup_wizard__date-selection-number-heading">
275 <label for="wpbc-date-selection-dynamic-min"><?php esc_html_e( 'Minimum days', 'booking' ); ?></label>
276 <input id="wpbc-date-selection-dynamic-min" type="number" name="date_selection_dynamic_min" min="1" max="365" step="1" value="<?php echo esc_attr( $values['date_selection_dynamic_min'] ); ?>" data-wpbc-setup-wizard-field data-wpbc-date-selection-number="date_selection_dynamic_min" required <?php disabled( ! $supports_advanced ); ?>>
277 </div>
278 <input class="wpbc_setup_wizard__date-selection-range" type="range" min="1" max="180" step="1" value="<?php echo esc_attr( $values['date_selection_dynamic_min'] ); ?>" data-wpbc-date-selection-range="date_selection_dynamic_min" aria-label="<?php esc_attr_e( 'Minimum flexible range length', 'booking' ); ?>" <?php disabled( ! $supports_advanced ); ?>>
279 </div>
280 <div class="wpbc_setup_wizard__date-selection-number-field">
281 <div class="wpbc_setup_wizard__date-selection-number-heading">
282 <label for="wpbc-date-selection-dynamic-max"><?php esc_html_e( 'Maximum days', 'booking' ); ?></label>
283 <input id="wpbc-date-selection-dynamic-max" type="number" name="date_selection_dynamic_max" min="1" max="365" step="1" value="<?php echo esc_attr( $values['date_selection_dynamic_max'] ); ?>" data-wpbc-setup-wizard-field data-wpbc-date-selection-number="date_selection_dynamic_max" required <?php disabled( ! $supports_advanced ); ?>>
284 </div>
285 <input class="wpbc_setup_wizard__date-selection-range" type="range" min="1" max="180" step="1" value="<?php echo esc_attr( $values['date_selection_dynamic_max'] ); ?>" data-wpbc-date-selection-range="date_selection_dynamic_max" aria-label="<?php esc_attr_e( 'Maximum flexible range length', 'booking' ); ?>" <?php disabled( ! $supports_advanced ); ?>>
286 </div>
287 </div>
288 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="date_selection_dynamic_min"></span>
289 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="date_selection_dynamic_max"></span>
290 <input type="hidden" name="date_selection_dynamic_weekdays" value="<?php echo esc_attr( $values['date_selection_dynamic_weekdays'] ); ?>" data-wpbc-setup-wizard-field data-wpbc-date-selection-weekday-transport="dynamic" required>
291 <div class="wpbc_setup_wizard__date-selection-weekdays" data-wpbc-date-selection-weekdays="dynamic" role="group" aria-label="<?php esc_attr_e( 'Allowed flexible range start days', 'booking' ); ?>">
292 <span><?php esc_html_e( 'A booking can start on', 'booking' ); ?></span>
293 <div>
294 <?php foreach ( $weekdays as $weekday ) : ?>
295 <button type="button" class="button<?php echo in_array( (string) $weekday['value'], $dynamic_weekdays, true ) ? ' is-selected' : ''; ?>" data-weekday="<?php echo esc_attr( (string) $weekday['value'] ); ?>" aria-pressed="<?php echo in_array( (string) $weekday['value'], $dynamic_weekdays, true ) ? 'true' : 'false'; ?>" title="<?php echo esc_attr( (string) $weekday['label'] ); ?>" <?php disabled( ! $supports_advanced ); ?>><?php echo esc_html( (string) $weekday['short_label'] ); ?></button>
296 <?php endforeach; ?>
297 </div>
298 </div>
299 <div class="wpbc_setup_wizard__date-selection-specific">
300 <label for="wpbc-date-selection-dynamic-specific"><?php esc_html_e( 'Specific number of days to select', 'booking' ); ?></label>
301 <input
302 id="wpbc-date-selection-dynamic-specific"
303 type="text"
304 name="date_selection_dynamic_specific"
305 value="<?php echo esc_attr( $values['date_selection_dynamic_specific'] ); ?>"
306 placeholder="<?php esc_attr_e( 'Example: 7,14,21,28', 'booking' ); ?>"
307 maxlength="500"
308 data-wpbc-setup-wizard-field
309 data-wpbc-date-selection-specific
310 <?php disabled( ! $supports_advanced ); ?>
311 >
312 <div class="wpbc_setup_wizard__date-selection-specific-presets" aria-label="<?php esc_attr_e( 'Specific day presets', 'booking' ); ?>">
313 <?php foreach ( $specific_day_presets as $specific_day_preset ) : ?>
314 <button
315 type="button"
316 class="button-link"
317 data-wpbc-date-selection-specific-preset="<?php echo esc_attr( (string) $specific_day_preset['value'] ); ?>"
318 <?php if ( null !== $specific_day_preset['minimum_days'] ) : ?>
319 data-wpbc-date-selection-preset-minimum="<?php echo esc_attr( (string) $specific_day_preset['minimum_days'] ); ?>"
320 <?php endif; ?>
321 <?php if ( null !== $specific_day_preset['maximum_days'] ) : ?>
322 data-wpbc-date-selection-preset-maximum="<?php echo esc_attr( (string) $specific_day_preset['maximum_days'] ); ?>"
323 <?php endif; ?>
324 <?php if ( null !== $specific_day_preset['start_weekdays'] ) : ?>
325 data-wpbc-date-selection-preset-weekdays="<?php echo esc_attr( (string) $specific_day_preset['start_weekdays'] ); ?>"
326 <?php endif; ?>
327 <?php disabled( ! $supports_advanced ); ?>
328 ><?php echo esc_html( (string) $specific_day_preset['label'] ); ?></button>
329 <?php endforeach; ?>
330 </div>
331 <span class="wpbc_setup_wizard__field-help"><?php esc_html_e( 'Allow only these stay lengths within the minimum and maximum range. Comma-separated numbers and ranges such as 3-5 are supported.', 'booking' ); ?></span>
332 <span class="wpbc_setup_wizard__field-help"><?php esc_html_e( 'Presets also set matching minimum, maximum, and start weekdays. Clear keeps those controls unchanged.', 'booking' ); ?></span>
333 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="date_selection_dynamic_specific"></span>
334 </div>
335 <?php if ( ! $supports_advanced ) : ?>
336 <p class="wpbc_setup_wizard__date-selection-locked-note wpbc_setup_wizard__message wpbc_setup_wizard__message--warning"><?php esc_html_e( 'This edition uses the unrestricted two-click flexible range. Custom range limits, specific stay lengths, and start weekdays require Business Small or higher.', 'booking' ); ?></p>
337 <?php endif; ?>
338 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="date_selection_dynamic_weekdays"></span>
339 </div>
340
341 </aside>
342
343 <section class="wpbc_setup_wizard__date-selection-changeover<?php echo $supports_advanced ? '' : ' is-locked'; ?>" aria-labelledby="wpbc-date-selection-changeover-title" data-wpbc-date-selection-changeover<?php if ( ! $changeover_is_visible ) : ?> hidden<?php endif; ?>>
344 <div class="wpbc_setup_wizard__date-selection-changeover-heading">
345 <h2 id="wpbc-date-selection-changeover-title"><?php esc_html_e( 'Changeover days', 'booking' ); ?></h2>
346 <?php if ( ! $supports_advanced ) : ?>
347 <span class="wpbc_setup_wizard__edition-badge"><?php esc_html_e( 'PRO / BS+', 'booking' ); ?></span>
348 <?php endif; ?>
349 <span
350 class="wpbc_ui__toggle wpbc_setup_wizard__date-selection-changeover-toggle"
351 data-wpbc-date-selection-disabled-tooltip="wpbc-date-selection-changeover-disabled-description"
352 <?php if ( ! $supports_advanced || 'required_on' === $changeover_policy ) : ?>
353 title="<?php echo esc_attr( ! $supports_advanced ? $advanced_toggle_disabled_reason : $changeover_journey_disabled_reason ); ?>"
354 tabindex="0"
355 aria-describedby="wpbc-date-selection-changeover-disabled-description"
356 data-wpbc-date-selection-disabled-tooltip-active="1"
357 <?php endif; ?>
358 >
359 <input
360 type="checkbox"
361 id="wpbc-date-selection-changeover-enabled"
362 class="wpbc_ui_checkbox"
363 aria-label="<?php esc_attr_e( 'Use changeover days', 'booking' ); ?>"
364 data-wpbc-date-selection-toggle="date_selection_changeover_enabled"
365 data-wpbc-date-selection-policy-state="<?php echo esc_attr( $changeover_policy ); ?>"
366 data-wpbc-date-selection-edition-locked="<?php echo $supports_advanced ? '0' : '1'; ?>"
367 data-wpbc-date-selection-disabled-reason="<?php echo esc_attr( ! $supports_advanced ? $advanced_toggle_disabled_reason : ( 'required_on' === $changeover_policy ? $changeover_journey_disabled_reason : '' ) ); ?>"
368 <?php checked( $changeover_is_enabled ); ?>
369 <?php disabled( ! $supports_advanced || 'required_on' === $changeover_policy ); ?>
370 >
371 <label class="wpbc_ui__toggle_icon" for="wpbc-date-selection-changeover-enabled"></label>
372 </span>
373 <span id="wpbc-date-selection-changeover-disabled-description" class="screen-reader-text" data-wpbc-date-selection-disabled-description><?php echo esc_html( ! $supports_advanced ? $advanced_toggle_disabled_reason : ( 'required_on' === $changeover_policy ? $changeover_journey_disabled_reason : '' ) ); ?></span>
374 <input type="hidden" name="date_selection_changeover_enabled" value="<?php echo esc_attr( $values['date_selection_changeover_enabled'] ); ?>" data-wpbc-setup-wizard-field required>
375 </div>
376 <div class="wpbc_setup_wizard__date-selection-changeover-visual wpbc_setup_wizard__journey-step--range-check-out" aria-hidden="true">
377 <span class="wpbc_setup_wizard__preview-calendar">
378 <?php for ( $changeover_calendar_index = 0; $changeover_calendar_index < 28; $changeover_calendar_index++ ) : ?>
379 <span></span>
380 <?php endfor; ?>
381 </span>
382 </div>
383 <p class="wpbc_setup_wizard__date-selection-changeover-help"><?php esc_html_e( 'Use arrival and departure boundaries for stays.', 'booking' ); ?></p>
384 <div
385 class="wpbc_setup_wizard__date-selection-changeover-controls"
386 data-wpbc-date-selection-changeover-controls
387 <?php if ( ! $changeover_is_enabled ) : ?> hidden<?php endif; ?>
388 >
389 <div class="wpbc_setup_wizard__date-selection-changeover-fields" data-wpbc-date-selection-changeover-fields>
390 <div class="wpbc_setup_wizard__date-selection-time-fields">
391 <label class="wpbc_setup_wizard__date-selection-time-field" for="wpbc-date-selection-check-in">
392 <span><?php esc_html_e( 'Guests check in at', 'booking' ); ?></span>
393 <select id="wpbc-date-selection-check-in" name="date_selection_check_in_time" data-wpbc-setup-wizard-field required <?php disabled( ! $supports_advanced ); ?>>
394 <?php foreach ( $time_options as $time_value => $time_label ) : ?>
395 <option value="<?php echo esc_attr( $time_value ); ?>" <?php selected( $values['date_selection_check_in_time'], $time_value ); ?>><?php echo esc_html( $time_label ); ?></option>
396 <?php endforeach; ?>
397 </select>
398 </label>
399 <label class="wpbc_setup_wizard__date-selection-time-field" for="wpbc-date-selection-check-out">
400 <span><?php esc_html_e( 'Guests check out at', 'booking' ); ?></span>
401 <select id="wpbc-date-selection-check-out" name="date_selection_check_out_time" data-wpbc-setup-wizard-field required <?php disabled( ! $supports_advanced ); ?>>
402 <?php foreach ( $time_options as $time_value => $time_label ) : ?>
403 <option value="<?php echo esc_attr( $time_value ); ?>" <?php selected( $values['date_selection_check_out_time'], $time_value ); ?>><?php echo esc_html( $time_label ); ?></option>
404 <?php endforeach; ?>
405 </select>
406 </label>
407 </div>
408 <div class="wpbc_setup_wizard__date-selection-changeover-option">
409 <label for="wpbc-date-selection-triangles"><?php esc_html_e( 'Show changeover days as triangles', 'booking' ); ?></label>
410 <span
411 class="wpbc_ui__toggle wpbc_setup_wizard__date-selection-changeover-option-toggle"
412 data-wpbc-date-selection-disabled-tooltip="wpbc-date-selection-triangles-disabled-description"
413 <?php if ( ! $supports_advanced ) : ?>
414 title="<?php echo esc_attr( $advanced_toggle_disabled_reason ); ?>"
415 tabindex="0"
416 aria-describedby="wpbc-date-selection-triangles-disabled-description"
417 data-wpbc-date-selection-disabled-tooltip-active="1"
418 <?php endif; ?>
419 >
420 <input type="checkbox" id="wpbc-date-selection-triangles" class="wpbc_ui_checkbox" data-wpbc-date-selection-toggle="date_selection_triangles" data-wpbc-date-selection-disabled-reason="<?php echo esc_attr( $supports_advanced ? '' : $advanced_toggle_disabled_reason ); ?>" <?php checked( 'On', $values['date_selection_triangles'] ); ?> <?php disabled( ! $supports_advanced ); ?>>
421 <label class="wpbc_ui__toggle_icon" for="wpbc-date-selection-triangles"></label>
422 </span>
423 <span id="wpbc-date-selection-triangles-disabled-description" class="screen-reader-text" data-wpbc-date-selection-disabled-description><?php echo esc_html( $supports_advanced ? '' : $advanced_toggle_disabled_reason ); ?></span>
424 </div>
425 <input type="hidden" name="date_selection_triangles" value="<?php echo esc_attr( $values['date_selection_triangles'] ); ?>" data-wpbc-setup-wizard-field required>
426 </div>
427 </div>
428 </section>
429
430 <section class="wpbc_setup_wizard__date-selection-behavior" aria-labelledby="wpbc-date-selection-behavior-title" data-wpbc-date-selection-behavior<?php if ( ! $behavior_is_visible ) : ?> hidden<?php endif; ?>>
431 <h2 id="wpbc-date-selection-behavior-title"><?php esc_html_e( 'Additional date behavior', 'booking' ); ?></h2>
432 <div class="wpbc_setup_wizard__date-selection-option" data-wpbc-date-selection-recurrent-option<?php if ( ! $recurrent_is_visible ) : ?> hidden<?php endif; ?>>
433 <span>
434 <label for="wpbc-date-selection-recurrent-time"><?php esc_html_e( 'Use selected times for each booking date', 'booking' ); ?></label>
435 <small><?php esc_html_e( 'Use selected times as booked time slots on each selected date.', 'booking' ); ?></small>
436 </span>
437 <span
438 class="wpbc_ui__toggle wpbc_setup_wizard__date-selection-option-toggle"
439 data-wpbc-date-selection-disabled-tooltip="wpbc-date-selection-recurrent-time-disabled-description"
440 <?php if ( 'required_on' === $recurrent_policy ) : ?>
441 title="<?php echo esc_attr( $recurrent_journey_disabled_reason ); ?>"
442 tabindex="0"
443 aria-describedby="wpbc-date-selection-recurrent-time-disabled-description"
444 data-wpbc-date-selection-disabled-tooltip-active="1"
445 <?php endif; ?>
446 >
447 <input type="checkbox" id="wpbc-date-selection-recurrent-time" class="wpbc_ui_checkbox" data-wpbc-date-selection-toggle="date_selection_recurrent_time" data-wpbc-date-selection-policy-state="<?php echo esc_attr( $recurrent_policy ); ?>" data-wpbc-date-selection-disabled-reason="<?php echo esc_attr( 'required_on' === $recurrent_policy ? $recurrent_journey_disabled_reason : '' ); ?>" <?php checked( 'On', $values['date_selection_recurrent_time'] ); ?> <?php disabled( 'required_on' === $recurrent_policy ); ?>>
448 <label class="wpbc_ui__toggle_icon" for="wpbc-date-selection-recurrent-time"></label>
449 </span>
450 <span id="wpbc-date-selection-recurrent-time-disabled-description" class="screen-reader-text" data-wpbc-date-selection-disabled-description><?php echo esc_html( 'required_on' === $recurrent_policy ? $recurrent_journey_disabled_reason : '' ); ?></span>
451 </div>
452 <input type="hidden" name="date_selection_recurrent_time" value="<?php echo esc_attr( $values['date_selection_recurrent_time'] ); ?>" data-wpbc-setup-wizard-field required>
453
454 <div
455 class="wpbc_setup_wizard__date-selection-option<?php echo $supports_advanced ? '' : ' is-locked'; ?>"
456 data-wpbc-date-selection-checkout-option
457 data-wpbc-date-selection-policy-state="<?php echo esc_attr( $checkout_policy ); ?>"
458 <?php if ( ! $checkout_is_supported ) : ?>
459 hidden
460 <?php endif; ?>
461 >
462 <span>
463 <label for="wpbc-date-selection-checkout-available"><?php esc_html_e( 'Set check out date as available', 'booking' ); ?></label>
464 <small><?php esc_html_e( 'Remove the last selected day from saving to the booking.', 'booking' ); ?></small>
465 </span>
466 <?php if ( ! $supports_advanced ) : ?>
467 <span class="wpbc_setup_wizard__edition-badge"><?php esc_html_e( 'PRO / BS+', 'booking' ); ?></span>
468 <?php endif; ?>
469 <span
470 class="wpbc_ui__toggle wpbc_setup_wizard__date-selection-option-toggle"
471 data-wpbc-date-selection-disabled-tooltip="wpbc-date-selection-checkout-disabled-description"
472 data-wpbc-date-selection-checkout-reason-edition="<?php echo esc_attr( $advanced_toggle_disabled_reason ); ?>"
473 data-wpbc-date-selection-checkout-reason-changeover="<?php echo esc_attr( $checkout_changeover_disabled_reason ); ?>"
474 data-wpbc-date-selection-checkout-reason-mode="<?php echo esc_attr( $checkout_mode_disabled_reason ); ?>"
475 <?php if ( '' !== $checkout_disabled_reason ) : ?>
476 title="<?php echo esc_attr( $checkout_disabled_reason ); ?>"
477 tabindex="0"
478 aria-describedby="wpbc-date-selection-checkout-disabled-description"
479 data-wpbc-date-selection-disabled-tooltip-active="1"
480 <?php endif; ?>
481 >
482 <input
483 type="checkbox"
484 id="wpbc-date-selection-checkout-available"
485 class="wpbc_ui_checkbox"
486 data-wpbc-date-selection-toggle="date_selection_checkout_available"
487 data-wpbc-date-selection-edition-locked="<?php echo $supports_advanced ? '0' : '1'; ?>"
488 data-wpbc-date-selection-disabled-reason="<?php echo esc_attr( $checkout_disabled_reason ); ?>"
489 <?php checked( $checkout_is_supported && ! $changeover_is_enabled && 'On' === $values['date_selection_checkout_available'] ); ?>
490 <?php disabled( ! $supports_advanced || ! $checkout_is_supported || $changeover_is_enabled ); ?>
491 >
492 <label class="wpbc_ui__toggle_icon" for="wpbc-date-selection-checkout-available"></label>
493 </span>
494 <span id="wpbc-date-selection-checkout-disabled-description" class="screen-reader-text" data-wpbc-date-selection-disabled-description><?php echo esc_html( $checkout_disabled_reason ); ?></span>
495 </div>
496 <input type="hidden" name="date_selection_checkout_available" value="<?php echo esc_attr( ! $checkout_is_supported || $changeover_is_enabled ? 'Off' : $values['date_selection_checkout_available'] ); ?>" data-wpbc-setup-wizard-field required>
497 </section>
498
499 <section class="wpbc_setup_wizard__date-selection-legend" aria-labelledby="wpbc-date-selection-legend-title" data-wpbc-date-selection-legend>
500 <div class="wpbc_setup_wizard__date-selection-section-heading">
501 <span>
502 <h2 id="wpbc-date-selection-legend-title"><?php esc_html_e( 'Calendar legend', 'booking' ); ?></h2>
503 <small><?php esc_html_e( 'Choose which date states customers see below the calendar.', 'booking' ); ?></small>
504 </span>
505 <span class="wpbc_ui__toggle wpbc_setup_wizard__date-selection-section-toggle">
506 <input type="checkbox" id="wpbc-date-selection-legend-enabled" class="wpbc_ui_checkbox" aria-label="<?php esc_attr_e( 'Show legend below calendar', 'booking' ); ?>" data-wpbc-date-selection-toggle="date_selection_legend_enabled" <?php checked( $legend_is_enabled ); ?>>
507 <label class="wpbc_ui__toggle_icon" for="wpbc-date-selection-legend-enabled"></label>
508 </span>
509 <input type="hidden" name="date_selection_legend_enabled" value="<?php echo esc_attr( $values['date_selection_legend_enabled'] ); ?>" data-wpbc-setup-wizard-field required>
510 </div>
511
512 <div class="wpbc_setup_wizard__date-selection-legend-settings" data-wpbc-date-selection-legend-settings<?php if ( ! $legend_is_enabled ) : ?> hidden<?php endif; ?>>
513 <div class="wpbc_setup_wizard__date-selection-legend-grid">
514 <?php foreach ( $legend_items as $legend_item ) : ?>
515 <?php
516 $legend_id = (string) $legend_item['id'];
517 $legend_item_key = 'date_selection_legend_item_' . $legend_id;
518 $legend_text_key = 'date_selection_legend_text_' . $legend_id;
519 $legend_control_id = 'wpbc-date-selection-legend-item-' . $legend_id;
520 $legend_text_id = 'wpbc-date-selection-legend-text-' . $legend_id;
521 $legend_toggle_label = sprintf(
522 /* translators: %s: Calendar legend item label. */
523 __( 'Show %s', 'booking' ),
524 (string) $legend_item['label']
525 );
526 ?>
527 <div class="wpbc_setup_wizard__date-selection-legend-item" data-wpbc-date-selection-legend-item="<?php echo esc_attr( $legend_id ); ?>">
528 <div class="wpbc_setup_wizard__date-selection-legend-item-heading">
529 <label for="<?php echo esc_attr( $legend_text_id ); ?>"><?php echo esc_html( (string) $legend_item['label'] ); ?></label>
530 <span class="wpbc_ui__toggle">
531 <input type="checkbox" id="<?php echo esc_attr( $legend_control_id ); ?>" class="wpbc_ui_checkbox" aria-label="<?php echo esc_attr( $legend_toggle_label ); ?>" data-wpbc-date-selection-toggle="<?php echo esc_attr( $legend_item_key ); ?>" <?php checked( 'On', $values[ $legend_item_key ] ); ?>>
532 <label class="wpbc_ui__toggle_icon" for="<?php echo esc_attr( $legend_control_id ); ?>"></label>
533 </span>
534 </div>
535 <input id="<?php echo esc_attr( $legend_text_id ); ?>" type="text" name="<?php echo esc_attr( $legend_text_key ); ?>" value="<?php echo esc_attr( $values[ $legend_text_key ] ); ?>" placeholder="<?php echo esc_attr( (string) $legend_item['placeholder'] ); ?>" maxlength="255" data-wpbc-setup-wizard-field data-wpbc-date-selection-legend-title="<?php echo esc_attr( $legend_id ); ?>">
536 <span class="wpbc_setup_wizard__field-error" data-wpbc-setup-wizard-error-for="<?php echo esc_attr( $legend_text_key ); ?>"></span>
537 <input type="hidden" name="<?php echo esc_attr( $legend_item_key ); ?>" value="<?php echo esc_attr( $values[ $legend_item_key ] ); ?>" data-wpbc-setup-wizard-field required>
538 </div>
539 <?php endforeach; ?>
540 </div>
541
542 <div class="wpbc_setup_wizard__date-selection-legend-options">
543 <div class="wpbc_setup_wizard__date-selection-option">
544 <label for="wpbc-date-selection-legend-show-numbers"><?php esc_html_e( 'Show date number in legend', 'booking' ); ?></label>
545 <span class="wpbc_ui__toggle wpbc_setup_wizard__date-selection-option-toggle">
546 <input type="checkbox" id="wpbc-date-selection-legend-show-numbers" class="wpbc_ui_checkbox" data-wpbc-date-selection-toggle="date_selection_legend_show_numbers" <?php checked( 'On', $values['date_selection_legend_show_numbers'] ); ?>>
547 <label class="wpbc_ui__toggle_icon" for="wpbc-date-selection-legend-show-numbers"></label>
548 </span>
549 </div>
550 <input type="hidden" name="date_selection_legend_show_numbers" value="<?php echo esc_attr( $values['date_selection_legend_show_numbers'] ); ?>" data-wpbc-setup-wizard-field required>
551 <div class="wpbc_setup_wizard__date-selection-option">
552 <label for="wpbc-date-selection-legend-vertical"><?php esc_html_e( 'Show legend items in a column', 'booking' ); ?></label>
553 <span class="wpbc_ui__toggle wpbc_setup_wizard__date-selection-option-toggle">
554 <input type="checkbox" id="wpbc-date-selection-legend-vertical" class="wpbc_ui_checkbox" data-wpbc-date-selection-toggle="date_selection_legend_vertical" <?php checked( 'On', $values['date_selection_legend_vertical'] ); ?>>
555 <label class="wpbc_ui__toggle_icon" for="wpbc-date-selection-legend-vertical"></label>
556 </span>
557 </div>
558 <input type="hidden" name="date_selection_legend_vertical" value="<?php echo esc_attr( $values['date_selection_legend_vertical'] ); ?>" data-wpbc-setup-wizard-field required>
559 </div>
560 </div>
561 </section>
562 </div>
563 </div>
564 </form>
565 </section>
566