PluginProbe
Booking Calendar / 11.6.1
Booking Calendar v11.6.1
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 10.11.2 All 203 releases
booking / includes / page-form-builder / builder-form-page.php

builder-form-page.php in Booking Calendar 11.6.1, at includes/page-form-builder/builder-form-page.php

804 lines 37.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Booking Form Builder – Admin Page.
4 *
5 * Responsibilities:
6 * - Register tab & page placement.
7 * - Capability & MU checks.
8 * - Render page scaffolding (containers only).
9 * - Enqueue assets and localize boot data.
10 *
11 * @package : Booking Calendar
12 * @subpackage : Admin Pages
13 * @Plugin_URI : https://wpbookingcalendar.com
14 * @Author_URI : https://wpbookingcalendar.com
15 * @Author : wpdevelop, oplugins
16 * @Version : 0.0.1
17 * @since : 10.14.x
18 * @modified : 2025-07-09
19 */
20
21 // ---------------------------------------------------------------------------------------------------------------------
22 // == File builder-form-page.php == Time point: 2025-08-29 12:25
23 // ---------------------------------------------------------------------------------------------------------------------
24 if ( ! defined( 'ABSPATH' ) ) {
25 exit; // Exit if accessed directly.
26 }
27
28
29 /** Show Content
30 * Update Content
31 * Define Slug
32 * Define where to show
33 */
34 class WPBC_Page_Builder_Booking_Form extends WPBC_Page_Structure {
35
36 // -- Tabs ---------------------------------------------------------------------------------------------------------
37
38 /**
39 * == What Page ? ==
40 *
41 * @return string
42 */
43 public function in_page() {
44 return 'wpbc-settings';
45 }
46
47 /**
48 * == Tabs ==
49 *
50 * @return array
51 */
52 public function tabs() {
53
54 $tabs = array();
55 $tabs['builder_booking_form'] = array(
56 'is_default_full_screen' => true, // true | false. By default value is: false.
57 'is_force_full_screen' => true, // true | false. Force full screen independently from user preference.
58 'is_show_top_path' => true, // true | false. By default value is: true.
59 'is_show_top_navigation' => false, // true | false. By default value is: false.
60 'right_vertical_sidebar__is_show' => true, // true | false. By default value is: false.
61 'right_vertical_sidebar__default_view_mode' => '', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
62 'right_vertical_sidebar_compact__is_show' => true, // true | false. By default value is: false.
63 'left_navigation__default_view_mode' => 'compact', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
64 'left_navigation__force_view_mode' => 'compact', // '' | 'min' | 'compact' | 'max' | 'none'. Force sidebar mode independently from user preference.
65
66 'top_path_title' => __( 'Forms Builder', 'booking' ),
67 'title' => __( 'Forms Builder', 'booking' ), // Title of TAB.
68 'hint' => '', //__( 'Define available and unavailable days for your calendar(s).', 'booking' ), // Hint.
69 'page_title' => __( 'Forms Builder', 'booking' ), // Title of Page.
70 'link' => '', // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link.
71 'position' => '', // 'left' / 'right' / ''.
72 'css_classes' => '', // CSS c l a s s(es).
73 'icon' => '', // Icon - link to the real PNG img.
74 'font_icon' => 'wpbc_icn_flip_x0 wpbc-bi-input-cursor-text 0layout-text-window-reverse', // 'wpbc_icn_free_cancellation' // CSS definition of forn Icon.
75 'font_icon_right' => '', // 'wpbc-bi-asterisk',
76 'default' => false, // Is this tab activated by default or not: true || false.
77 'disabled' => false, // Is this tab disbaled: true || false.
78 'hided' => false, // Is this tab hided: true || false.
79 'subtabs' => array(),
80 'folder_style' => 'order:12;',
81 );
82 return $tabs;
83 }
84
85 // -- Right Sidebar -----------------------------------------------------------------------------------------------
86
87 /**
88 * == Right | Sidebar Compact | Content ==
89 *
90 * @return void
91 */
92 public function right_sidebar_compact_content() {
93 ?>
94 <div class="wpbc_bfb__rightbar_tabs" role="tablist" aria-label="<?php esc_attr_e( 'Form Builder Panels', 'booking' ); ?>">
95 <div class="wpbc_ui_el__level__folder">
96 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
97 <button type="button" id="wpbc_tab_library"
98 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
99 role="tab" aria-controls="wpbc_bfb__palette_add_new" aria-selected="true" >
100 <i class="wpbc_ui_el__vert_nav_icon tooltip_right_offset menu_icon icon-1x wpbc_icn_add_circle" aria-hidden="true" data-original-title="<?php esc_attr_e( 'Add New Fields', 'booking' ); ?>"></i>
101 <span><?php esc_html_e( 'Add Fields', 'booking' ); ?></span>
102 </button>
103 </div>
104 </div>
105 <div class="wpbc_ui_el__level__folder">
106 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
107 <button type="button" id="wpbc_tab_inspector"
108 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
109 role="tab" aria-controls="wpbc_bfb__inspector" aria-selected="false" >
110 <i class="wpbc_ui_el__vert_nav_icon tooltip_right_offset menu_icon icon-1x wpbc-bi-input-cursor-text" aria-hidden="true" data-original-title="<?php esc_attr_e( 'Edit Field Options', 'booking' ); ?>"></i>
111 <span><?php esc_html_e( 'Edit Field', 'booking' ); ?></span>
112 </button>
113 </div>
114 </div>
115 <div class="wpbc_ui_el__level__folder">
116 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
117 <button type="button" id="wpbc_tab_formdetails"
118 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
119 role="tab" aria-controls="wpbc_bfb__inspector_form_details" aria-selected="false" >
120 <i class="wpbc_ui_el__vert_nav_icon tooltip_right_offset menu_icon icon-1x 0wpbc_icn_widgets 0wpbc_icn_rotate_90 wpbc-bi-postcard" aria-hidden="true" data-original-title="<?php esc_attr_e( 'Details', 'booking' ); ?>"></i>
121 <span><?php esc_html_e( 'Details', 'booking' ); ?></span>
122 </button>
123 </div>
124 </div>
125 <div class="wpbc_ui_el__level__folder">
126 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
127 <button type="button" id="wpbc_tab_form"
128 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
129 role="tab" aria-controls="wpbc_bfb__inspector_form_settings" aria-selected="false" >
130 <i class="wpbc_ui_el__vert_nav_icon tooltip_right_offset menu_icon icon-1x wpbc_icn_tune" aria-hidden="true" data-original-title="<?php esc_attr_e( 'Booking Form Settings', 'booking' ); ?>"></i>
131 <span><?php esc_html_e( 'Settings', 'booking' ); ?></span>
132 </button>
133 </div>
134 </div>
135 <?php // FixIn: 10.15.5.5. ?>
136 <!-- Code Tools default hidden -->
137 <div class="wpbc_ui_el__level__folder wpbc_bfb__rightbar_tab_wrap wpbc_bfb__rightbar_tab_wrap--advanced_tools" hidden>
138 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
139 <button type="button" id="wpbc_tab_advanced_tools"
140 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
141 role="tab"
142 aria-controls="wpbc_bfb__inspector_advanced_tools"
143 aria-selected="false">
144 <i class="wpbc_ui_el__vert_nav_icon tooltip_right_offset menu_icon icon-1x wpbc_icn_code_off wpbc_icn_rotate_180"
145 aria-hidden="true"
146 data-original-title="<?php esc_attr_e( 'Help and generator for Advanced Mode', 'booking' ); ?>"></i>
147 <span><?php esc_html_e( 'Shortcodes', 'booking' ); ?></span>
148 </button>
149 </div>
150 </div>
151 </div>
152 <?php
153 }
154
155 /**
156 * == Right Sidebar Content ==
157 *
158 * @return void
159 */
160 public function right_sidebar_content() {
161 ?>
162 <!-- RIGHT SIDE: Panels container -->
163 <div class="wpbc_bfb__panel--library">
164 <!-- Add Fields (Library) default visible -->
165 <div id="wpbc_bfb__palette_add_new"
166 class="wpbc_bfb__palette_add_new wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
167 role="tabpanel"
168 aria-labelledby="wpbc_tab_library"
169 aria-hidden="false">
170 <?php
171 $this->palette_add_new__content();
172 ?>
173 </div>
174
175 <!-- Edit Field (Inspector) default hidden -->
176 <div id="wpbc_bfb__inspector"
177 class="wpbc_bfb__inspector wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
178 role="tabpanel"
179 aria-labelledby="wpbc_tab_inspector"
180 hidden
181 aria-hidden="true">
182 <div class="wpbc_bfb__inspector__body">
183 <div class="wpbc_bfb__inspector__empty">
184 <?php
185 esc_html_e( 'Select a field to edit its options.', 'booking' );
186 ?>
187 </div>
188 </div>
189 </div>
190
191 <!-- Settings Options default hidden -->
192 <div id="wpbc_bfb__inspector_form_settings"
193 class="wpbc_bfb__inspector_form_settings wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
194 role="tabpanel"
195 aria-labelledby="wpbc_tab_form"
196 hidden
197 aria-hidden="true">
198 <div class="wpbc_bfb__inspector__head">
199 <div class="header_container">
200 <div class="header_title_content">
201 <h3 class="title"><?php esc_html_e( 'Global Form Settings', 'booking' ); ?></h3>
202 <div class="desc"><?php esc_html_e( 'Setup settings for entire form. These settings usually aplies globally to all forms.', 'booking' ); ?></div>
203 </div>
204 </div>
205 </div>
206 <div class="wpbc_bfb__inspector__body">
207 <?php
208 wpbc_bfb_ui__settings_options__print();
209 ?>
210 </div>
211 </div>
212
213 <!-- Settings Options default hidden -->
214 <div id="wpbc_bfb__inspector_form_details"
215 class="wpbc_bfb__inspector_form_details wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
216 role="tabpanel"
217 aria-labelledby="wpbc_tab_formdetails"
218 hidden
219 aria-hidden="true">
220 <div class="wpbc_bfb__inspector__head">
221 <div class="header_container">
222 <div class="header_title_content">
223 <h3 class="title"><?php esc_html_e( 'Form Details', 'booking' ); ?></h3>
224 <div class="desc"><?php esc_html_e( 'These details are saved together with the form when you click “Save Form”.', 'booking' ); ?></div>
225 </div>
226 </div>
227 </div>
228 <div class="wpbc_bfb__inspector__body">
229 <?php
230 wpbc_bfb_ui__current_form_details__print();
231 ?>
232 </div>
233 </div>
234
235 <?php // FixIn: 10.15.5.5. ?>
236 <!-- Advanced Mode Tools default hidden -->
237 <div id="wpbc_bfb__inspector_advanced_tools"
238 class="wpbc_bfb__inspector_advanced_tools wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
239 role="tabpanel"
240 aria-labelledby="wpbc_tab_advanced_tools"
241 hidden
242 aria-hidden="true">
243 <div class="wpbc_bfb__inspector__head">
244 <div class="header_container">
245 <div class="header_title_content">
246 <h3 class="title"><?php esc_html_e( 'Advanced Mode Tools', 'booking' ); ?></h3>
247 <div class="desc"><?php esc_html_e( 'Generate booking form code, review examples, and get help while working in Advanced Mode.', 'booking' ); ?></div>
248 </div>
249 </div>
250 </div>
251
252 <div class="wpbc_bfb__inspector__body">
253
254 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-booking_essentials">
255 <button type="button" class="group__header">
256 <h3><?php esc_html_e( 'Booking Essentials', 'booking' ); ?></h3>
257 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
258 </button>
259 <div class="group__fields">
260 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__booking_essentials' ); ?>
261 </div>
262 </section>
263
264 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group is-open" data-group="advanced-mode-fields">
265 <button type="button" class="group__header">
266 <h3><?php esc_html_e( 'Fields', 'booking' ); ?></h3>
267 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
268 </button>
269 <div class="group__fields">
270 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__fields' ); ?>
271 </div>
272 </section>
273
274 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-time_services">
275 <button type="button" class="group__header">
276 <h3><?php esc_html_e( 'Time & Services', 'booking' ); ?></h3>
277 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
278 </button>
279 <div class="group__fields">
280 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__time_services' ); ?>
281 </div>
282 </section>
283
284 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-layouts">
285 <button type="button" class="group__header">
286 <h3><?php esc_html_e( 'Layouts', 'booking' ); ?></h3>
287 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
288 </button>
289 <div class="group__fields">
290 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__layouts' ); ?>
291 </div>
292 </section>
293
294 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-hints">
295 <button type="button" class="group__header">
296 <h3><?php esc_html_e( 'Hints', 'booking' ); ?></h3>
297 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
298 </button>
299 <div class="group__fields">
300 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__hints' ); ?>
301 </div>
302 </section>
303
304 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-conditional_rules">
305 <button type="button" class="group__header">
306 <h3><?php esc_html_e( 'Conditional Rules', 'booking' ); ?></h3>
307 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
308 </button>
309 <div class="group__fields">
310 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__conditional_rules' ); ?>
311 </div>
312 </section>
313
314 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-simple_html_layout">
315 <button type="button" class="group__header">
316 <h3><?php esc_html_e( 'Simple HTML Layout', 'booking' ); ?></h3>
317 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
318 </button>
319 <div class="group__fields">
320 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__simple_html_layout' ); ?>
321 </div>
322 </section>
323
324 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-tips_and_tricks">
325 <button type="button" class="group__header">
326 <h3><?php esc_html_e( 'Tips and Tricks', 'booking' ); ?></h3>
327 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
328 </button>
329 <div class="group__fields">
330 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__tips_and_tricks' ); ?>
331 </div>
332 </section>
333
334 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-other_fields">
335 <button type="button" class="group__header">
336 <h3><?php esc_html_e( 'Other Fields', 'booking' ); ?></h3>
337 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
338 </button>
339 <div class="group__fields">
340 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__other_fields' ); ?>
341 </div>
342 </section>
343
344 </div>
345 </div>
346
347 </div>
348 <?php
349 }
350
351 /**
352 * "Add New Fields" - "Palette" - Right Side.
353 *
354 * @return void
355 */
356 private function palette_add_new__content() {
357 ?>
358 <div class="wpbc_bfb__inspector__body">
359 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group is-open" data-group="fields-essentials">
360 <button type="button" class="group__header"><h3><?php esc_html_e( 'Booking Essentials', 'booking' ); ?></h3><i
361 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
362 </button>
363 <div class="group__fields">
364 <ul class="wpbc_bfb__panel_field_types__ul">
365 <?php
366 /** Let packs target "general" if they want */
367 do_action( 'wpbc_bfb_palette_register_items', 'essentials', 'top' );
368 do_action( 'wpbc_bfb_palette_register_items', 'essentials', 'bottom' );
369 ?>
370 </ul>
371 </div>
372 </section>
373
374 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-standard">
375 <button type="button" class="group__header"><h3><?php esc_html_e( 'Fields', 'booking' ); ?></h3><i
376 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
377 </button>
378 <div class="group__fields">
379 <ul class="wpbc_bfb__panel_field_types__ul">
380 <?php
381 /** Let packs target "general" if they want */
382 do_action( 'wpbc_bfb_palette_register_items', 'standard', 'top' );
383 do_action( 'wpbc_bfb_palette_register_items', 'standard', 'bottom' );
384 ?>
385 </ul>
386 </div>
387 </section>
388
389 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-times">
390 <button type="button" class="group__header"><h3><?php esc_html_e( 'Time & Services', 'booking' ); ?></h3><i
391 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
392 </button>
393 <div class="group__fields">
394 <ul class="wpbc_bfb__panel_field_types__ul">
395 <?php
396 /** Let packs target "general" if they want */
397 do_action( 'wpbc_bfb_palette_register_items', 'times', 'top' );
398 do_action( 'wpbc_bfb_palette_register_items', 'times', 'bottom' );
399 ?>
400 </ul>
401 </div>
402 </section>
403
404 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-layout">
405 <button type="button" class="group__header"><h3><?php esc_html_e( 'Layout', 'booking' ); ?></h3><i
406 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
407 </button>
408 <div class="group__fields">
409 <ul class="wpbc_bfb__panel_field_types__ul">
410 <?php
411 /** Let packs target "structure" if they want */
412 do_action( 'wpbc_bfb_palette_register_items', 'layout', 'top' );
413 do_action( 'wpbc_bfb_palette_register_items', 'layout', 'bottom' );
414 ?>
415 </ul>
416 </div>
417 </section>
418
419 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-navigation">
420 <button type="button" class="group__header"><h3><?php esc_html_e( 'Multi-Step & Navigation', 'booking' ); ?></h3><i
421 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
422 </button>
423 <div class="group__fields">
424
425 <ul class="wpbc_bfb__panel_field_types__ul">
426 <?php
427 /** Let packs target "advanced" if they want */
428 do_action( 'wpbc_bfb_palette_register_items', 'navigation', 'top' );
429 do_action( 'wpbc_bfb_palette_register_items', 'navigation', 'bottom' );
430 ?>
431 </ul>
432
433 </div>
434 </section>
435
436
437 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-hints_dates">
438 <button type="button" class="group__header">
439 <h3><?php
440 esc_html_e( 'Date & Time Hints', 'booking' ); ?></h3>
441 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
442 </button>
443 <div class="group__fields">
444
445 <ul class="wpbc_bfb__panel_field_types__ul">
446 <?php
447 do_action( 'wpbc_bfb_palette_register_items', 'hints_dates', 'top' );
448 do_action( 'wpbc_bfb_palette_register_items', 'hints_dates', 'bottom' );
449 ?>
450 </ul>
451
452 </div>
453 </section>
454
455 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-hints">
456 <button type="button" class="group__header">
457 <h3><?php
458 esc_html_e( 'Cost Hints', 'booking' ); ?></h3>
459 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
460 </button>
461 <div class="group__fields">
462
463 <ul class="wpbc_bfb__panel_field_types__ul">
464 <?php
465 do_action( 'wpbc_bfb_palette_register_items', 'hints', 'top' );
466 do_action( 'wpbc_bfb_palette_register_items', 'hints', 'bottom' );
467 ?>
468 </ul>
469
470 </div>
471 </section>
472
473 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-hints_other">
474 <button type="button" class="group__header">
475 <h3><?php
476 esc_html_e( 'Booking Info Hints', 'booking' ); ?></h3>
477 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
478 </button>
479 <div class="group__fields">
480
481 <ul class="wpbc_bfb__panel_field_types__ul">
482 <?php
483 do_action( 'wpbc_bfb_palette_register_items', 'hints_other', 'top' );
484 do_action( 'wpbc_bfb_palette_register_items', 'hints_other', 'bottom' );
485 ?>
486 </ul>
487
488 </div>
489 </section>
490
491
492
493 </div>
494 <?php
495 }
496
497 // -- Content ------------------------------------------------------------------------------------------------------
498
499 /**
500 * == Page Content ==
501 *
502 * @return false|void
503 */
504 public function content() {
505
506 do_action( 'wpbc_hook_settings_page_header', 'page_booking_builder_booking_form' ); // Define Notices Section and show some static messages, if needed.
507
508 if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { return false; } // Check if MU user activated, otherwise show Warning message.
509 // if ( ! wpbc_set_default_resource_to__get() ) return false; // Define default booking resources for $_GET and check if booking resource belong to user.
510 wpbc_js_for_bookings_page(); // JavaScript functions.
511
512 wpbc_bfb__adavanced_mode__enqueue_code_editor_for_advanced_tab();
513
514 wpbc_bfb__ui__show_warning__no_mobile_mode();
515
516 echo '<div id="wpbc_log_screen" class="wpbc_log_screen"></div>';
517
518 wpbc_bfb__ui__add_columns_control();
519
520 // == Expose AJAX settings to JS on the Builder page ==
521 wpbc_bfb_output_ajax_boot_config();
522
523 // == Top Horizontal menu ==
524 $tabs_config = array(
525 'builder_tab' => array(
526 'title' => __( 'Form Builder', 'booking' ) . ' (Visual)',
527 'type' => 'panel',
528 'css_classes' => '',
529 'data_attr' => array(
530 'data-wpbc-bfb-top-builder-btn' => '1',
531 ),
532 ),
533 'advanced_tab' => array(
534 'title' => __( 'Advanced Mode', 'booking' ) . ' (Code)',
535 'type' => 'panel',
536 'css_classes' => '',
537 'data_attr' => array(
538 'data-wpbc-bfb-top-advanced-btn' => '1',
539 ),
540 ),
541 );
542 $tabs_config['debug_tab'] = array(
543 'title' => __( 'Debug', 'booking' ),
544 'type' => 'panel',
545 'css_classes' => 'align_right small_debug_tab',
546 'hint' => array(
547 'title' => __( 'Show debug export outputs', 'booking' ),
548 'position' => 'top',
549 ),
550 );
551
552 $tabs_config = apply_filters( 'wpbc_bfb_ui__top_tabs', $tabs_config, array() );
553
554 $preferred_tab_id = 'builder_tab'; //TODO: make selection based on "bfb_options":{"advanced_mode_source":"builder"}
555 $active_tab_id = WPBC_BFB_UI_Top_Tabs::resolve_active_tab_id( $tabs_config, $preferred_tab_id );
556
557 WPBC_BFB_UI_Top_Tabs::render(
558 array(
559 'active_tab' => $active_tab_id,
560 'tabs' => $tabs_config,
561 'nav_container_id' => 'wpbc_bfb__top_horisontal_nav',
562 'panels_root_id' => 'wpbc_bfb__top_panels',
563 'panel_base_class' => 'wpbc_bfb__top_tab_section',
564 )
565 );
566
567
568 // == Content ==
569 ?>
570 <div id="wpbc_bfb__top_panels">
571 <!-- BFB Content. -->
572 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__builder_tab wpbc_bfb__top_tab_section wpbc_bfb__top_tab_section__builder_tab" <?php echo WPBC_BFB_UI_Top_Tabs::get_panel_hidden_attr( 'builder_tab', $active_tab_id );/* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>>
573 <div class="wpbc_bfb__container">
574 <!-- LEFT SIDE: Pages -->
575 <div id="wpbc_bfb__theme_scope" class="wpbc_bfb__theme_scope">
576 <div id="wpbc_bfb__pages_panel" class="wpbc_bfb__pages_panel">
577 <!-- Events binded to this element! -->
578 <div id="wpbc_bfb__pages_container">
579 <!-- This is loader spin -->
580 <div class="wpbc_bfb__panel wpbc_bfb__panel--preview wpbc_bfb_form wpbc_container wpbc_form wpbc_container_booking_form">
581 <div class="wpbc_bfb__form_preview_section_container wpbc_wizard__border_container" style="margin: 20px 0;box-sizing: border-box;width: auto;min-height: Min(50vh, 300px);display: flex;flex-flow: column nowrap;justify-content: center;" >
582 <?php wpbc_bfb_spins_loading_container_mini(); ?>
583 </div>
584 </div>
585 </div>
586 <div style="display:flex;margin:20px;flex-flow: row wrap;align-items: center;justify-content: center;">
587 <button class="button button-primary wpbc_ui_button wpbc_bs_button_green" id="wpbc_bfb__add_page_btn" aria-label="<?php esc_attr_e( 'Add Page', 'booking' ); ?>">+ <?php esc_html_e( 'Add Page', 'booking' ); ?></button>
588 </div>
589 </div>
590 </div>
591 </div>
592 </div>
593 <!-- Advanced Mode Content tab -->
594 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__advanced_tab wpbc_bfb__top_tab_section wpbc_bfb__top_tab_section__advanced_tab"
595 <?php echo WPBC_BFB_UI_Top_Tabs::get_panel_hidden_attr( 'advanced_tab', $active_tab_id ); /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>
596 ><?php
597
598 //--------------------------------------------------------------------------------------------------------------
599 // 'Upgrade to Pro' widget
600 //--------------------------------------------------------------------------------------------------------------
601 $upgrade_content_arr = wpbc_get_upgrade_widget(
602 array(
603 'id' => 'widget_wpbc_dismiss__booking_form_advanced_mode',
604 'dismiss_css_class' => '.wpbc_dismiss__booking_form_advanced_mode',
605 'blured_in_versions' => array( 'free' ),
606 'feature_link' => array( 'title' => 'feature', 'relative_url' => 'overview/#booking-resources' ),
607 'upgrade_link' => array( 'title' => 'Upgrade to Pro', 'relative_url' => 'features/#bk_news_section' ),
608 'versions' => 'paid versions',
609 'css' => 'transform: translate(0) translateY(290px);',
610 'no_dismiss' => true
611 )
612 );
613 echo $upgrade_content_arr['content']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
614
615 ?><div class="<?php echo esc_attr( $upgrade_content_arr['maybe_blur_css_class'] ); ?>"><?php
616
617 wpbc_bfb__adavanced_mode__render_advanced_form_editor_panel();
618
619 ?></div><?php
620
621 ?>
622 </div>
623 <!-- Debug Mode tab -->
624 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__debug_tab wpbc_bfb__top_tab_section wpbc_bfb__top_tab_section__debug_tab"
625 <?php echo WPBC_BFB_UI_Top_Tabs::get_panel_hidden_attr( 'debug_tab', $active_tab_id ); /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>>
626
627 <div id="wpbc_bfb__debug_export_panel" class="wpbc_bfb__debug_export_panel" aria-hidden="false">
628 <!-- JS (builder-exporter.js) will inject three debug textareas here -->
629
630 <!-- Tabs -->
631 <?php
632
633 $tabs_config_debug = array(
634 'debug_mode__export' => array(
635 'title' => __( 'Export', 'booking' ),
636 'type' => 'panel',
637 'css_classes' => '',
638 ),
639 'debug_mode__import' => array(
640 'title' => __( 'Import', 'booking' ),
641 'type' => 'panel',
642 'css_classes' => '',
643 ),
644 'debug_mode__actual_bfb' => array(
645 'title' => __( 'Actual Builder Code', 'booking' ),
646 'type' => 'panel',
647 'css_classes' => '',
648 ),
649 );
650
651 WPBC_BFB_UI_Top_Tabs::render(
652 array(
653 'active_tab' => 'debug_mode__export',
654 'tabs' => $tabs_config_debug,
655 'nav_container_id' => 'wpbc_bfb__top_horisontal__debug_mode',
656 'panels_root_id' => 'wpbc_bfb__debug_mode_panels',
657 )
658 );
659
660 ?>
661 <div id="wpbc_bfb__debug_mode_panels">
662
663
664 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__debug_mode__export">
665 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--structure" style="margin-top: 14px;">
666 <h4><?php
667 esc_html_e( 'Form Structure', 'booking' ); echo ''; esc_html_e( 'Export', 'booking' ); echo ' (JSON)'; ?></h4>
668 <textarea id="wpbc_bfb__structure_output" readonly="readonly"></textarea>
669 <div style="margin-top: 8px;">
670 <button type="button" class="button" data-wpbc-bfb-debug-action="copy" data-wpbc-bfb-debug-target="wpbc_bfb__structure_output"><?php esc_html_e( 'Copy to Clipboard', 'booking' ); ?></button>
671 </div>
672 </div>
673 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--settings" style="margin-top: 14px;">
674 <h4><?php esc_html_e( 'Form Settings', 'booking' ); echo ''; esc_html_e( 'Export', 'booking' ); echo ' (JSON)'; ?></h4>
675 <textarea id="wpbc_bfb__settings_output" readonly="readonly"></textarea>
676 <div style="margin-top: 8px;">
677 <button type="button" class="button" data-wpbc-bfb-debug-action="copy" data-wpbc-bfb-debug-target="wpbc_bfb__settings_output"><?php esc_html_e( 'Copy to Clipboard', 'booking' ); ?></button>
678 </div>
679 </div>
680 <div style="flex:1 1 100%;"></div>
681 <button type="button" class="button wpbc_bfb__debug_separate_button"
682 onclick="var structure = window.wpbc_bfb && window.wpbc_bfb.get_structure ? window.wpbc_bfb.get_structure() : null; console.log(JSON.stringify(structure, null, 2));">
683 <?php esc_html_e( 'Print JSON Structure in Browser Console', 'booking' ); ?>
684 </button>
685 </div>
686
687 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__debug_mode__import">
688 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--structure-import" style="margin-top: 14px;">
689 <h4><?php esc_html_e( 'Form Structure', 'booking' ); echo ''; esc_html_e( 'Import', 'booking' ); echo ' (JSON)'; ?></h4>
690 <textarea id="wpbc_bfb__structure_import" ></textarea>
691 <div style="margin-top: 8px;">
692 <button type="button" class="button" data-wpbc-bfb-debug-action="copy" data-wpbc-bfb-debug-target="wpbc_bfb__structure_import"><?php esc_html_e( 'Copy to Clipboard', 'booking' ); ?></button>
693 <button type="button" class="button button-primary" data-wpbc-bfb-debug-action="apply_structure"><?php esc_html_e( 'Apply Structure', 'booking' ); ?></button>
694 </div>
695 </div>
696 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--settings-import" style="margin-top: 14px;">
697 <h4><?php esc_html_e( 'Form Settings', 'booking' ); echo ''; esc_html_e( 'Import', 'booking' ); echo ' (JSON)'; ?></h4>
698 <textarea id="wpbc_bfb__settings_import" ></textarea>
699 <div style="margin-top: 8px;">
700 <button type="button" class="button" data-wpbc-bfb-debug-action="copy" data-wpbc-bfb-debug-target="wpbc_bfb__settings_import"><?php esc_html_e( 'Copy to Clipboard', 'booking' ); ?></button>
701 <button type="button" class="button button-primary" data-wpbc-bfb-debug-action="apply_settings"><?php esc_html_e( 'Apply Settings', 'booking' ); ?></button>
702 </div>
703 </div>
704 <div style="flex:1 1 100%;"></div>
705 <button type="button" class="button wpbc_bfb__debug_separate_button" data-wpbc-bfb-debug-action="apply_both"><?php esc_html_e( 'Apply Both', 'booking' ); ?></button>
706 </div>
707
708 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__debug_mode__actual_bfb">
709 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--advanced" style="margin-top: 14px;">
710 <h4><?php esc_html_e( 'Advanced Form', 'booking' ); echo ''; esc_html_e( 'Export', 'booking' ); echo ' (CODE)'; ?></h4>
711 <textarea id="wpbc_bfb__advanced_form_output"readonly="readonly"></textarea>
712 <div style="margin-top: 8px;">
713 <button type="button" class="button" data-wpbc-bfb-debug-action="copy" data-wpbc-bfb-debug-target="wpbc_bfb__advanced_form_output"><?php esc_html_e( 'Copy to Clipboard', 'booking' ); ?></button>
714 </div>
715 </div>
716 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--content" style="margin-top: 14px;">
717 <h4><?php esc_html_e( 'Content of booking fields data', 'booking' ); echo ''; esc_html_e( 'Export', 'booking' ); echo ' (CODE)'; ?></h4>
718 <textarea id="wpbc_bfb__content_form_output"readonly="readonly"></textarea>
719 <div style="margin-top: 8px;">
720 <button type="button" class="button" data-wpbc-bfb-debug-action="copy" data-wpbc-bfb-debug-target="wpbc_bfb__content_form_output"><?php esc_html_e( 'Copy to Clipboard', 'booking' ); ?></button>
721 </div>
722 </div>
723 </div>
724
725 </div>
726
727 </div>
728 </div>
729
730 <!-- Preview Section Content tab -->
731 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__preview_tab wpbc_bfb__top_tab_section wpbc_bfb__top_tab_section__preview_tab"
732 <?php echo WPBC_BFB_UI_Top_Tabs::get_panel_hidden_attr( 'preview_tab', $active_tab_id ); /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>>
733 <?php wpbc_bfb_render_preview_panel(); ?>
734 </div>
735 </div>
736 <?php
737
738 // == Hidden Templates for - Booking Actions ==
739 do_action( 'wpbc_hook_bfb_template__hidden_templates' );
740
741 do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking_builder_booking_form' );
742 }
743 }
744
745 add_action( 'wpbc_menu_created', array( new WPBC_Page_Builder_Booking_Form(), '__construct' ) ); // Executed after creation of Menu.
746
747
748 // == One-way redirect from removed legacy form settings ===============================================================
749
750 /**
751 * Disable showing removed legacy "WP Booking Calendar > Settings > Booking Form" page.
752 *
753 * @param bool $is_show - 'usually' - true.
754 * @param string $page_tag - can be 'wpbc-settings'.
755 * @param string $active_page_tab - can be 'form'.
756 * @param string $active_page_subtab - can be 'booking_form_fields'.
757 *
758 * @return false|mixed
759 */
760 function wpbc_form_fields__check__showing_page( $is_show, $page_tag, $active_page_tab, $active_page_subtab ) {
761
762 if ( ( 'form' === $active_page_tab ) && ( 'wpbc-settings' === $page_tag ) ) {
763 $is_show = false;
764 }
765
766 return $is_show;
767 }
768 // Important here to have priority 20 instead of 10, because it can be ovveriden by same hook in MU, where we check 'check_for_active_users'.
769 add_filter( 'wpbc_before_showing_settings_page_is_show_page', 'wpbc_form_fields__check__showing_page', 20, 4 );
770
771
772 /**
773 * Unset removed legacy Form menu in vertical left menu widget.
774 *
775 * @param array $nav_tabs - array of menus.
776 * @param string $this_page - current selected page.
777 *
778 * @return mixed
779 */
780 function wpbc_form_fields__check__plugin_menu_structure( $nav_tabs, $this_page ) {
781
782 if ( isset( $nav_tabs['wpbc-settings'] ) && isset( $nav_tabs['wpbc-settings']['form'] ) ) {
783 unset( $nav_tabs['wpbc-settings']['form'] );
784 }
785
786 return $nav_tabs;
787 }
788 add_filter( 'wpbc_plugin_menu_structure_arr', 'wpbc_form_fields__check__plugin_menu_structure', 20, 2 );
789
790
791 /** Trick here to overload default REQUST parameters before page is loading */
792 function wpbc_form_fields__check__define_page_redirect( $page_tag ) {
793
794 // $page_tag - here can be all defined in plugin menu pages. So we need to check activated page. By default its inside of $_GET['page'].
795 // Execute it only for WP Booking Calendar > Settings > Booking Form > Booking Form Fields page.
796
797 if ( wpbc_is_settings_form_page() ) {
798 // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
799 wp_redirect( admin_url( "admin.php?page=wpbc-settings&tab=builder_booking_form" ) );
800 }
801 }
802 // We are set 9 to execute earlier than hook in WPBC_Admin_Menus.
803 add_action( 'wpbc_define_nav_tabs', 'wpbc_form_fields__check__define_page_redirect', 9 ); // This Hook fire in the class WPBC_Admin_Menus for showing page content of specific menu
804