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-fixed-time-slots / template.php

template.php in Booking Calendar 11.9, at includes/page-setup-wizard/step-fixed-time-slots/template.php

159 lines 9.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Sortable fixed time-slot setup editor presentation.
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 $draft_field_name = isset( $step_data['draft_field_name'] ) ? sanitize_key( (string) $step_data['draft_field_name'] ) : 'fixed_time_slots';
15 $draft_values = isset( $step_data['draft_values'] ) && is_array( $step_data['draft_values'] ) ? $step_data['draft_values'] : array();
16 $editor_title = isset( $step_data['editor_title'] ) ? sanitize_text_field( (string) $step_data['editor_title'] ) : __( 'Set fixed time slots', 'booking' );
17 $editor_description = isset( $step_data['editor_description'] ) ? sanitize_text_field( (string) $step_data['editor_description'] ) : __( 'Choose the fixed time slots customers can use when booking.', 'booking' );
18 $list_title = isset( $step_data['list_title'] ) ? sanitize_text_field( (string) $step_data['list_title'] ) : __( 'Fixed time slots', 'booking' );
19 $list_description = isset( $step_data['list_description'] ) ? sanitize_text_field( (string) $step_data['list_description'] ) : __( 'Choices shown in the booking form.', 'booking' );
20 $list_label = isset( $step_data['list_label'] ) ? sanitize_text_field( (string) $step_data['list_label'] ) : $list_title;
21 $time_options = isset( $step_data['time_options'] ) && is_array( $step_data['time_options'] ) ? $step_data['time_options'] : array();
22 $end_time_options = isset( $step_data['end_time_options'] ) && is_array( $step_data['end_time_options'] ) ? $step_data['end_time_options'] : array();
23 $interval_options = isset( $step_data['interval_options'] ) && is_array( $step_data['interval_options'] ) ? $step_data['interval_options'] : array();
24 $duration_options = isset( $step_data['duration_options'] ) && is_array( $step_data['duration_options'] ) ? $step_data['duration_options'] : array();
25 $generator_from = isset( $step_data['generator_from'] ) ? (string) $step_data['generator_from'] : '10:00';
26 $generator_to = isset( $step_data['generator_to'] ) ? (string) $step_data['generator_to'] : '14:30';
27 $generator_interval = isset( $step_data['generator_interval'] ) ? absint( $step_data['generator_interval'] ) : 30;
28 $generator_duration = isset( $step_data['generator_duration'] ) ? absint( $step_data['generator_duration'] ) : 30;
29 $max_time_slots = isset( $step_data['max_time_slots'] ) ? absint( $step_data['max_time_slots'] ) : 288;
30 $time_increment = isset( $step_data['time_increment'] ) ? absint( $step_data['time_increment'] ) : 5;
31 $draft_values_json = wp_json_encode( $draft_values );
32 $draft_values_json = false === $draft_values_json ? '{}' : $draft_values_json;
33 $field_error_id = 'wpbc-setup-wizard-fixed-time-slots-error';
34 $list_title_id = 'wpbc-setup-wizard-fixed-time-slots-list-title';
35 ?>
36 <section class="wpbc_setup_wizard__step-content wpbc_setup_wizard__fixed-slots-step" aria-labelledby="wpbc-setup-wizard-step-title">
37 <header class="wpbc_setup_wizard__step-heading">
38 <h1 id="wpbc-setup-wizard-step-title"><?php echo esc_html( $editor_title ); ?></h1>
39 <p class="wpbc_setup_wizard__lead"><?php echo esc_html( $editor_description ); ?></p>
40 </header>
41 <?php
42 $template_context['templates']->render(
43 'settings-hint',
44 array( 'settings_hint' => $template_context['settings_hint'] )
45 );
46 ?>
47
48 <form id="wpbc-setup-wizard-step-form" novalidate>
49 <input
50 type="hidden"
51 name="<?php echo esc_attr( $draft_field_name ); ?>"
52 value="<?php echo esc_attr( $draft_values_json ); ?>"
53 required
54 data-wpbc-setup-wizard-field
55 data-wpbc-fixed-slots-draft
56 data-max-time-slots="<?php echo esc_attr( (string) $max_time_slots ); ?>"
57 data-time-increment="<?php echo esc_attr( (string) $time_increment ); ?>"
58 aria-describedby="<?php echo esc_attr( $field_error_id ); ?>"
59 >
60
61 <div class="wpbc_setup_wizard__fixed-slots-editor" data-wpbc-fixed-slots-editor data-field-id="<?php echo esc_attr( $draft_field_name ); ?>">
62 <section class="wpbc_setup_wizard__fixed-slots-panel" aria-labelledby="<?php echo esc_attr( $list_title_id ); ?>">
63 <div class="wpbc_setup_wizard__fixed-slots-toolbar">
64 <div class="wpbc_setup_wizard__fixed-slots-heading">
65 <h2 id="<?php echo esc_attr( $list_title_id ); ?>"><?php echo esc_html( $list_title ); ?></h2>
66 <p><?php echo esc_html( $list_description ); ?></p>
67 </div>
68
69 <div class="wpbc_setup_wizard__fixed-slots-generator" data-wpbc-fixed-slots-generator>
70 <label>
71 <span><?php esc_html_e( 'From', 'booking' ); ?></span>
72 <select data-wpbc-fixed-generator-from>
73 <?php foreach ( $time_options as $option ) : ?>
74 <option value="<?php echo esc_attr( (string) $option['value'] ); ?>" <?php selected( $generator_from, (string) $option['value'] ); ?>><?php echo esc_html( (string) $option['label'] ); ?></option>
75 <?php endforeach; ?>
76 </select>
77 </label>
78 <label>
79 <span><?php echo esc_html_x( 'To', 'range end', 'booking' ); ?></span>
80 <select data-wpbc-fixed-generator-to aria-describedby="wpbc-fixed-slots-to-description">
81 <?php foreach ( $time_options as $option ) : ?>
82 <option value="<?php echo esc_attr( (string) $option['value'] ); ?>" <?php selected( $generator_to, (string) $option['value'] ); ?>><?php echo esc_html( (string) $option['label'] ); ?></option>
83 <?php endforeach; ?>
84 </select>
85 <span class="screen-reader-text" id="wpbc-fixed-slots-to-description"><?php esc_html_e( 'Last generated slot start time', 'booking' ); ?></span>
86 </label>
87 <label>
88 <span><?php esc_html_e( 'Every', 'booking' ); ?></span>
89 <select data-wpbc-fixed-generator-interval>
90 <?php foreach ( $interval_options as $interval_option ) : ?>
91 <option value="<?php echo esc_attr( (string) $interval_option['value'] ); ?>" <?php selected( $generator_interval, (int) $interval_option['value'] ); ?>><?php echo esc_html( (string) $interval_option['label'] ); ?></option>
92 <?php endforeach; ?>
93 </select>
94 </label>
95 <label>
96 <span><?php esc_html_e( 'Duration', 'booking' ); ?></span>
97 <select data-wpbc-fixed-generator-duration>
98 <?php foreach ( $duration_options as $duration_option ) : ?>
99 <option value="<?php echo esc_attr( (string) $duration_option['value'] ); ?>" <?php selected( $generator_duration, (int) $duration_option['value'] ); ?>><?php echo esc_html( (string) $duration_option['label'] ); ?></option>
100 <?php endforeach; ?>
101 </select>
102 </label>
103 <button type="button" class="button button-secondary wpbc_setup_wizard__fixed-slots-generate" data-wpbc-generate-fixed-slots>
104 <i class="menu_icon icon-1x wpbc_icn_add" aria-hidden="true"></i>
105 <span><?php esc_html_e( 'Generate times', 'booking' ); ?></span>
106 </button>
107 </div>
108 </div>
109
110 <div class="wpbc_setup_wizard__fixed-slots-body">
111 <div
112 class="wpbc_setup_wizard__fixed-slot-list"
113 data-wpbc-fixed-slot-list
114 data-list-label="<?php echo esc_attr( $list_label ); ?>"
115 aria-label="<?php echo esc_attr( $list_label ); ?>"
116 ></div>
117 <div class="wpbc_setup_wizard__fixed-slots-actions">
118 <button type="button" class="button button-secondary wpbc_setup_wizard__fixed-slot-add" data-wpbc-add-fixed-slot>
119 <i class="menu_icon icon-1x wpbc_icn_add" aria-hidden="true"></i>
120 <span><?php esc_html_e( 'Add one time slot', 'booking' ); ?></span>
121 </button>
122 <button type="button" class="button-link wpbc_setup_wizard__fixed-slots-clear" data-wpbc-clear-fixed-slots>
123 <?php esc_html_e( 'Clear times', 'booking' ); ?>
124 </button>
125 </div>
126 </div>
127 </section>
128
129 <template data-wpbc-fixed-slot-template>
130 <div class="wpbc_setup_wizard__fixed-slot">
131 <button type="button" class="wpbc_setup_wizard__fixed-slot-move" data-wpbc-move-fixed-slot>
132 <i class="menu_icon icon-1x wpbc_icn_drag_indicator" aria-hidden="true"></i>
133 <span class="screen-reader-text"><?php esc_html_e( 'Move fixed time slot', 'booking' ); ?></span>
134 </button>
135 <label class="screen-reader-text" data-wpbc-fixed-slot-start-label><?php esc_html_e( 'Fixed time slot start', 'booking' ); ?></label>
136 <select data-wpbc-fixed-slot-start>
137 <?php foreach ( $time_options as $option ) : ?>
138 <option value="<?php echo esc_attr( (string) $option['value'] ); ?>"><?php echo esc_html( (string) $option['label'] ); ?></option>
139 <?php endforeach; ?>
140 </select>
141 <span class="wpbc_setup_wizard__fixed-slot-separator" aria-hidden="true">&ndash;</span>
142 <label class="screen-reader-text" data-wpbc-fixed-slot-end-label><?php esc_html_e( 'Fixed time slot end', 'booking' ); ?></label>
143 <select data-wpbc-fixed-slot-end>
144 <?php foreach ( $end_time_options as $option ) : ?>
145 <option value="<?php echo esc_attr( (string) $option['value'] ); ?>"><?php echo esc_html( (string) $option['label'] ); ?></option>
146 <?php endforeach; ?>
147 </select>
148 <button type="button" class="wpbc_setup_wizard__fixed-slot-remove" data-wpbc-remove-fixed-slot>
149 <i class="menu_icon icon-1x wpbc_icn_delete_outline" aria-hidden="true"></i>
150 <span class="screen-reader-text"><?php esc_html_e( 'Remove fixed time slot', 'booking' ); ?></span>
151 </button>
152 </div>
153 </template>
154 </div>
155
156 <span class="wpbc_setup_wizard__field-error wpbc_setup_wizard__field-error--group" id="<?php echo esc_attr( $field_error_id ); ?>" data-wpbc-setup-wizard-error-for="<?php echo esc_attr( $draft_field_name ); ?>"></span>
157 </form>
158 </section>
159