PluginProbe
Booking Calendar / 11.2
Booking Calendar v11.2
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.2, at includes/page-form-builder/builder-form-page.php

821 lines 38.0 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_show_top_path' => false, // true | false. By default value is: false.
58 'is_show_top_navigation' => false, // true | false. By default value is: false.
59 'right_vertical_sidebar__is_show' => true, // true | false. By default value is: false.
60 'right_vertical_sidebar__default_view_mode' => '', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
61 'right_vertical_sidebar_compact__is_show' => true, // true | false. By default value is: false.
62 'left_navigation__default_view_mode' => 'compact', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
63
64 'title' => __( 'Forms Builder', 'booking' ) . // Title of TAB.
65 '<span class="wpbc_new_label" style="margin-left: auto;">' . esc_html__( 'New', 'booking' ) . '</span>',
66 'hint' => '', //__( 'Define available and unavailable days for your calendar(s).', 'booking' ), // Hint.
67 'page_title' => __( 'Forms Builder', 'booking' ), // Title of Page.
68 'link' => '', // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link.
69 'position' => '', // 'left' / 'right' / ''.
70 'css_classes' => '', // CSS c l a s s(es).
71 'icon' => '', // Icon - link to the real PNG img.
72 'font_icon' => 'wpbc_icn_flip_x0 wpbc-bi-input-cursor-text 0layout-text-window-reverse', // 'wpbc_icn_free_cancellation' // CSS definition of forn Icon.
73 'font_icon_right' => '', // 'wpbc-bi-asterisk',
74 'default' => false, // Is this tab activated by default or not: true || false.
75 'disabled' => false, // Is this tab disbaled: true || false.
76 'hided' => false, // Is this tab hided: true || false.
77 'subtabs' => array(),
78 'folder_style' => 'order:12;',
79 );
80 return $tabs;
81 }
82
83 // -- Right Sidebar -----------------------------------------------------------------------------------------------
84
85 /**
86 * == Right | Sidebar Compact | Content ==
87 *
88 * @return void
89 */
90 public function right_sidebar_compact_content() {
91 ?>
92 <div class="wpbc_bfb__rightbar_tabs" role="tablist" aria-label="<?php esc_attr_e( 'Form Builder Panels', 'booking' ); ?>">
93 <div class="wpbc_ui_el__level__folder">
94 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
95 <button type="button" id="wpbc_tab_library"
96 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
97 role="tab" aria-controls="wpbc_bfb__palette_add_new" aria-selected="true" >
98 <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>
99 <span><?php esc_html_e( 'Add Fields', 'booking' ); ?></span>
100 </button>
101 </div>
102 </div>
103 <div class="wpbc_ui_el__level__folder">
104 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
105 <button type="button" id="wpbc_tab_inspector"
106 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
107 role="tab" aria-controls="wpbc_bfb__inspector" aria-selected="false" >
108 <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>
109 <span><?php esc_html_e( 'Edit Field', 'booking' ); ?></span>
110 </button>
111 </div>
112 </div>
113 <div class="wpbc_ui_el__level__folder">
114 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
115 <button type="button" id="wpbc_tab_formdetails"
116 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
117 role="tab" aria-controls="wpbc_bfb__inspector_form_details" aria-selected="false" >
118 <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>
119 <span><?php esc_html_e( 'Details', 'booking' ); ?></span>
120 </button>
121 </div>
122 </div>
123 <div class="wpbc_ui_el__level__folder">
124 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
125 <button type="button" id="wpbc_tab_form"
126 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
127 role="tab" aria-controls="wpbc_bfb__inspector_form_settings" aria-selected="false" >
128 <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>
129 <span><?php esc_html_e( 'Settings', 'booking' ); ?></span>
130 </button>
131 </div>
132 </div>
133 <?php // FixIn: 10.15.5.5. ?>
134 <!-- Code Tools default hidden -->
135 <div class="wpbc_ui_el__level__folder wpbc_bfb__rightbar_tab_wrap wpbc_bfb__rightbar_tab_wrap--advanced_tools" hidden>
136 <div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__builder_booking_form">
137 <button type="button" id="wpbc_tab_advanced_tools"
138 class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single"
139 role="tab"
140 aria-controls="wpbc_bfb__inspector_advanced_tools"
141 aria-selected="false">
142 <i class="wpbc_ui_el__vert_nav_icon tooltip_right_offset menu_icon icon-1x wpbc_icn_code_off wpbc_icn_rotate_180"
143 aria-hidden="true"
144 data-original-title="<?php esc_attr_e( 'Help and generator for Advanced Mode', 'booking' ); ?>"></i>
145 <span><?php esc_html_e( 'Shortcodes', 'booking' ); ?></span>
146 </button>
147 </div>
148 </div>
149 </div>
150 <?php
151 }
152
153 /**
154 * == Right Sidebar Content ==
155 *
156 * @return void
157 */
158 public function right_sidebar_content() {
159 ?>
160 <!-- RIGHT SIDE: Panels container -->
161 <div class="wpbc_bfb__panel--library">
162 <!-- Add Fields (Library) default visible -->
163 <div id="wpbc_bfb__palette_add_new"
164 class="wpbc_bfb__palette_add_new wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
165 role="tabpanel"
166 aria-labelledby="wpbc_tab_library"
167 aria-hidden="false">
168 <?php
169 $this->palette_add_new__content();
170 ?>
171 </div>
172
173 <!-- Edit Field (Inspector) default hidden -->
174 <div id="wpbc_bfb__inspector"
175 class="wpbc_bfb__inspector wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
176 role="tabpanel"
177 aria-labelledby="wpbc_tab_inspector"
178 hidden
179 aria-hidden="true">
180 <div class="wpbc_bfb__inspector__body">
181 <div class="wpbc_bfb__inspector__empty">
182 <?php
183 esc_html_e( 'Select a field to edit its options.', 'booking' );
184 ?>
185 </div>
186 </div>
187 </div>
188
189 <!-- Settings Options default hidden -->
190 <div id="wpbc_bfb__inspector_form_settings"
191 class="wpbc_bfb__inspector_form_settings wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
192 role="tabpanel"
193 aria-labelledby="wpbc_tab_form"
194 hidden
195 aria-hidden="true">
196 <div class="wpbc_bfb__inspector__head">
197 <div class="header_container">
198 <div class="header_title_content">
199 <h3 class="title"><?php esc_html_e( 'Global Form Settings', 'booking' ); ?></h3>
200 <div class="desc"><?php esc_html_e( 'Setup settings for entire form. These settings usually aplies globally to all forms.', 'booking' ); ?></div>
201 </div>
202 </div>
203 </div>
204 <div class="wpbc_bfb__inspector__body">
205 <?php
206 wpbc_bfb_ui__settings_options__print();
207 ?>
208 </div>
209 </div>
210
211 <!-- Settings Options default hidden -->
212 <div id="wpbc_bfb__inspector_form_details"
213 class="wpbc_bfb__inspector_form_details wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
214 role="tabpanel"
215 aria-labelledby="wpbc_tab_formdetails"
216 hidden
217 aria-hidden="true">
218 <div class="wpbc_bfb__inspector__head">
219 <div class="header_container">
220 <div class="header_title_content">
221 <h3 class="title"><?php esc_html_e( 'Form Details', 'booking' ); ?></h3>
222 <div class="desc"><?php esc_html_e( 'These details are saved together with the form when you click “Save Form”.', 'booking' ); ?></div>
223 </div>
224 </div>
225 </div>
226 <div class="wpbc_bfb__inspector__body">
227 <?php
228 wpbc_bfb_ui__current_form_details__print();
229 ?>
230 </div>
231 </div>
232
233 <?php // FixIn: 10.15.5.5. ?>
234 <!-- Advanced Mode Tools default hidden -->
235 <div id="wpbc_bfb__inspector_advanced_tools"
236 class="wpbc_bfb__inspector_advanced_tools wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive"
237 role="tabpanel"
238 aria-labelledby="wpbc_tab_advanced_tools"
239 hidden
240 aria-hidden="true">
241 <div class="wpbc_bfb__inspector__head">
242 <div class="header_container">
243 <div class="header_title_content">
244 <h3 class="title"><?php esc_html_e( 'Advanced Mode Tools', 'booking' ); ?></h3>
245 <div class="desc"><?php esc_html_e( 'Generate booking form code, review examples, and get help while working in Advanced Mode.', 'booking' ); ?></div>
246 </div>
247 </div>
248 </div>
249
250 <div class="wpbc_bfb__inspector__body">
251
252 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-booking_essentials">
253 <button type="button" class="group__header">
254 <h3><?php esc_html_e( 'Booking Essentials', 'booking' ); ?></h3>
255 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
256 </button>
257 <div class="group__fields">
258 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__booking_essentials' ); ?>
259 </div>
260 </section>
261
262 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group is-open" data-group="advanced-mode-fields">
263 <button type="button" class="group__header">
264 <h3><?php esc_html_e( 'Fields', 'booking' ); ?></h3>
265 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
266 </button>
267 <div class="group__fields">
268 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__fields' ); ?>
269 </div>
270 </section>
271
272 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-time_services">
273 <button type="button" class="group__header">
274 <h3><?php esc_html_e( 'Time & Services', 'booking' ); ?></h3>
275 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
276 </button>
277 <div class="group__fields">
278 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__time_services' ); ?>
279 </div>
280 </section>
281
282 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-layouts">
283 <button type="button" class="group__header">
284 <h3><?php esc_html_e( 'Layouts', 'booking' ); ?></h3>
285 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
286 </button>
287 <div class="group__fields">
288 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__layouts' ); ?>
289 </div>
290 </section>
291
292 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-hints">
293 <button type="button" class="group__header">
294 <h3><?php esc_html_e( 'Hints', 'booking' ); ?></h3>
295 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
296 </button>
297 <div class="group__fields">
298 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__hints' ); ?>
299 </div>
300 </section>
301
302 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-conditional_rules">
303 <button type="button" class="group__header">
304 <h3><?php esc_html_e( 'Conditional Rules', 'booking' ); ?></h3>
305 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
306 </button>
307 <div class="group__fields">
308 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__conditional_rules' ); ?>
309 </div>
310 </section>
311
312 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-simple_html_layout">
313 <button type="button" class="group__header">
314 <h3><?php esc_html_e( 'Simple HTML Layout', 'booking' ); ?></h3>
315 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
316 </button>
317 <div class="group__fields">
318 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__simple_html_layout' ); ?>
319 </div>
320 </section>
321
322 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-tips_and_tricks">
323 <button type="button" class="group__header">
324 <h3><?php esc_html_e( 'Tips and Tricks', 'booking' ); ?></h3>
325 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
326 </button>
327 <div class="group__fields">
328 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__tips_and_tricks' ); ?>
329 </div>
330 </section>
331
332 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced-mode-other_fields">
333 <button type="button" class="group__header">
334 <h3><?php esc_html_e( 'Other Fields', 'booking' ); ?></h3>
335 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
336 </button>
337 <div class="group__fields">
338 <?php do_action( 'wpbc_bfb_advanced_mode_sidebar__other_fields' ); ?>
339 </div>
340 </section>
341
342 </div>
343 </div>
344
345 </div>
346 <?php
347 }
348
349 /**
350 * "Add New Fields" - "Palette" - Right Side.
351 *
352 * @return void
353 */
354 private function palette_add_new__content() {
355 ?>
356 <div class="wpbc_bfb__inspector__body">
357 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group is-open" data-group="fields-essentials">
358 <button type="button" class="group__header"><h3><?php esc_html_e( 'Booking Essentials', 'booking' ); ?></h3><i
359 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
360 </button>
361 <div class="group__fields">
362 <ul class="wpbc_bfb__panel_field_types__ul">
363 <?php
364 /** Let packs target "general" if they want */
365 do_action( 'wpbc_bfb_palette_register_items', 'essentials', 'top' );
366 do_action( 'wpbc_bfb_palette_register_items', 'essentials', 'bottom' );
367 ?>
368 </ul>
369 </div>
370 </section>
371
372 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-standard">
373 <button type="button" class="group__header"><h3><?php esc_html_e( 'Fields', 'booking' ); ?></h3><i
374 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
375 </button>
376 <div class="group__fields">
377 <ul class="wpbc_bfb__panel_field_types__ul">
378 <?php
379 /** Let packs target "general" if they want */
380 do_action( 'wpbc_bfb_palette_register_items', 'standard', 'top' );
381 do_action( 'wpbc_bfb_palette_register_items', 'standard', 'bottom' );
382 ?>
383 </ul>
384 </div>
385 </section>
386
387 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-times">
388 <button type="button" class="group__header"><h3><?php esc_html_e( 'Time & Services', 'booking' ); ?></h3><i
389 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
390 </button>
391 <div class="group__fields">
392 <ul class="wpbc_bfb__panel_field_types__ul">
393 <?php
394 /** Let packs target "general" if they want */
395 do_action( 'wpbc_bfb_palette_register_items', 'times', 'top' );
396 do_action( 'wpbc_bfb_palette_register_items', 'times', 'bottom' );
397 ?>
398 </ul>
399 </div>
400 </section>
401
402 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-layout">
403 <button type="button" class="group__header"><h3><?php esc_html_e( 'Layout', 'booking' ); ?></h3><i
404 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
405 </button>
406 <div class="group__fields">
407 <ul class="wpbc_bfb__panel_field_types__ul">
408 <?php
409 /** Let packs target "structure" if they want */
410 do_action( 'wpbc_bfb_palette_register_items', 'layout', 'top' );
411 do_action( 'wpbc_bfb_palette_register_items', 'layout', 'bottom' );
412 ?>
413 </ul>
414 </div>
415 </section>
416
417 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-navigation">
418 <button type="button" class="group__header"><h3><?php esc_html_e( 'Multi-Step & Navigation', 'booking' ); ?></h3><i
419 class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
420 </button>
421 <div class="group__fields">
422
423 <ul class="wpbc_bfb__panel_field_types__ul">
424 <?php
425 /** Let packs target "advanced" if they want */
426 do_action( 'wpbc_bfb_palette_register_items', 'navigation', 'top' );
427 do_action( 'wpbc_bfb_palette_register_items', 'navigation', 'bottom' );
428 ?>
429 </ul>
430
431 </div>
432 </section>
433
434
435 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-hints_dates">
436 <button type="button" class="group__header">
437 <h3><?php
438 esc_html_e( 'Date & Time Hints', 'booking' ); ?></h3>
439 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
440 </button>
441 <div class="group__fields">
442
443 <ul class="wpbc_bfb__panel_field_types__ul">
444 <?php
445 do_action( 'wpbc_bfb_palette_register_items', 'hints_dates', 'top' );
446 do_action( 'wpbc_bfb_palette_register_items', 'hints_dates', 'bottom' );
447 ?>
448 </ul>
449
450 </div>
451 </section>
452
453 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-hints">
454 <button type="button" class="group__header">
455 <h3><?php
456 esc_html_e( 'Cost Hints', 'booking' ); ?></h3>
457 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
458 </button>
459 <div class="group__fields">
460
461 <ul class="wpbc_bfb__panel_field_types__ul">
462 <?php
463 do_action( 'wpbc_bfb_palette_register_items', 'hints', 'top' );
464 do_action( 'wpbc_bfb_palette_register_items', 'hints', 'bottom' );
465 ?>
466 </ul>
467
468 </div>
469 </section>
470
471 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="fields-hints_other">
472 <button type="button" class="group__header">
473 <h3><?php
474 esc_html_e( 'Booking Info Hints', 'booking' ); ?></h3>
475 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
476 </button>
477 <div class="group__fields">
478
479 <ul class="wpbc_bfb__panel_field_types__ul">
480 <?php
481 do_action( 'wpbc_bfb_palette_register_items', 'hints_other', 'top' );
482 do_action( 'wpbc_bfb_palette_register_items', 'hints_other', 'bottom' );
483 ?>
484 </ul>
485
486 </div>
487 </section>
488
489
490
491 </div>
492 <?php
493 }
494
495 // -- Content ------------------------------------------------------------------------------------------------------
496
497 /**
498 * == Page Content ==
499 *
500 * @return false|void
501 */
502 public function content() {
503
504 do_action( 'wpbc_hook_settings_page_header', 'page_booking_builder_booking_form' ); // Define Notices Section and show some static messages, if needed.
505
506 if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { return false; } // Check if MU user activated, otherwise show Warning message.
507 // if ( ! wpbc_set_default_resource_to__get() ) return false; // Define default booking resources for $_GET and check if booking resource belong to user.
508 wpbc_js_for_bookings_page(); // JavaScript functions.
509
510 wpbc_bfb__adavanced_mode__enqueue_code_editor_for_advanced_tab();
511
512 wpbc_bfb__ui__show_warning__no_mobile_mode();
513
514 echo '<div id="wpbc_log_screen" class="wpbc_log_screen"></div>';
515
516 wpbc_bfb__ui__add_columns_control();
517
518 // == Expose AJAX settings to JS on the Builder page ==
519 wpbc_bfb_output_ajax_boot_config();
520
521 // == Top Horizontal menu ==
522 $tabs_config = array(
523 'builder_tab' => array(
524 'title' => __( 'Form Builder', 'booking' ) . ' (Visual)',
525 'type' => 'panel',
526 'css_classes' => '',
527 'data_attr' => array(
528 'data-wpbc-bfb-top-builder-btn' => '1',
529 ),
530 ),
531 'advanced_tab' => array(
532 'title' => __( 'Advanced Mode', 'booking' ) . ' (Code)',
533 'type' => 'panel',
534 'css_classes' => '',
535 'data_attr' => array(
536 'data-wpbc-bfb-top-advanced-btn' => '1',
537 ),
538 ),
539 );
540 if ( WPBC_BFB_DEBUG ) {
541 $tabs_config['debug_tab'] = array(
542 'title' => __( 'Debug', 'booking' ),
543 'type' => 'panel',
544 'css_classes' => 'align_right small_debug_tab',
545 'hint' => array(
546 'title' => __( 'Show debug export outputs', 'booking' ),
547 'position' => 'top',
548 ),
549 );
550 }
551 $tabs_config = apply_filters( 'wpbc_bfb_ui__top_tabs', $tabs_config, array() );
552
553 // $preferred_tab_id = ( 'On' === get_bk_option( 'booking_is_use_simple_booking_form' ) ) ? 'advanced_tab' : 'builder_tab';
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 <?php if ( WPBC_BFB_DEBUG ) { ?>
624 <!-- Debug Mode tab -->
625 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__debug_tab wpbc_bfb__top_tab_section wpbc_bfb__top_tab_section__debug_tab"
626 <?php echo WPBC_BFB_UI_Top_Tabs::get_panel_hidden_attr( 'debug_tab', $active_tab_id ); /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>>
627
628 <div id="wpbc_bfb__debug_export_panel" class="wpbc_bfb__debug_export_panel" aria-hidden="false">
629 <!-- JS (builder-exporter.js) will inject three debug textareas here -->
630
631 <!-- Tabs -->
632 <?php
633
634 $tabs_config_debug = array(
635 'debug_mode__export' => array(
636 'title' => __( 'Export', 'booking' ),
637 'type' => 'panel',
638 'css_classes' => '',
639 ),
640 'debug_mode__import' => array(
641 'title' => __( 'Import', 'booking' ),
642 'type' => 'panel',
643 'css_classes' => '',
644 ),
645 'debug_mode__actual_bfb' => array(
646 'title' => __( 'Actual Builder Code', 'booking' ),
647 'type' => 'panel',
648 'css_classes' => '',
649 ),
650 );
651
652 WPBC_BFB_UI_Top_Tabs::render(
653 array(
654 'active_tab' => 'debug_mode__export',
655 'tabs' => $tabs_config_debug,
656 'nav_container_id' => 'wpbc_bfb__top_horisontal__debug_mode',
657 'panels_root_id' => 'wpbc_bfb__debug_mode_panels',
658 )
659 );
660
661 ?>
662 <div id="wpbc_bfb__debug_mode_panels">
663
664
665 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__debug_mode__export">
666 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--structure" style="margin-top: 14px;">
667 <h4><?php
668 esc_html_e( 'Form Structure', 'booking' ); echo ''; esc_html_e( 'Export', 'booking' ); echo ' (JSON)'; ?></h4>
669 <textarea id="wpbc_bfb__structure_output" readonly="readonly"></textarea>
670 <div style="margin-top: 8px;">
671 <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>
672 </div>
673 </div>
674 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--settings" style="margin-top: 14px;">
675 <h4><?php esc_html_e( 'Form Settings', 'booking' ); echo ''; esc_html_e( 'Export', 'booking' ); echo ' (JSON)'; ?></h4>
676 <textarea id="wpbc_bfb__settings_output" readonly="readonly"></textarea>
677 <div style="margin-top: 8px;">
678 <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>
679 </div>
680 </div>
681 <div style="flex:1 1 100%;"></div>
682 <button type="button" class="button wpbc_bfb__debug_separate_button"
683 onclick="var structure = window.wpbc_bfb && window.wpbc_bfb.get_structure ? window.wpbc_bfb.get_structure() : null; console.log(JSON.stringify(structure, null, 2));">
684 <?php esc_html_e( 'Print JSON Structure in Browser Console', 'booking' ); ?>
685 </button>
686 </div>
687
688 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__debug_mode__import">
689 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--structure-import" style="margin-top: 14px;">
690 <h4><?php esc_html_e( 'Form Structure', 'booking' ); echo ''; esc_html_e( 'Import', 'booking' ); echo ' (JSON)'; ?></h4>
691 <textarea id="wpbc_bfb__structure_import" ></textarea>
692 <div style="margin-top: 8px;">
693 <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>
694 <button type="button" class="button button-primary" data-wpbc-bfb-debug-action="apply_structure"><?php esc_html_e( 'Apply Structure', 'booking' ); ?></button>
695 </div>
696 </div>
697 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--settings-import" style="margin-top: 14px;">
698 <h4><?php esc_html_e( 'Form Settings', 'booking' ); echo ''; esc_html_e( 'Import', 'booking' ); echo ' (JSON)'; ?></h4>
699 <textarea id="wpbc_bfb__settings_import" ></textarea>
700 <div style="margin-top: 8px;">
701 <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>
702 <button type="button" class="button button-primary" data-wpbc-bfb-debug-action="apply_settings"><?php esc_html_e( 'Apply Settings', 'booking' ); ?></button>
703 </div>
704 </div>
705 <div style="flex:1 1 100%;"></div>
706 <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>
707 </div>
708
709 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__debug_mode__actual_bfb">
710 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--advanced" style="margin-top: 14px;">
711 <h4><?php esc_html_e( 'Advanced Form', 'booking' ); echo ''; esc_html_e( 'Export', 'booking' ); echo ' (CODE)'; ?></h4>
712 <textarea id="wpbc_bfb__advanced_form_output"readonly="readonly"></textarea>
713 <div style="margin-top: 8px;">
714 <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>
715 </div>
716 </div>
717 <div class="wpbc_bfb__debug_block wpbc_bfb__debug_block--content" style="margin-top: 14px;">
718 <h4><?php esc_html_e( 'Content of booking fields data', 'booking' ); echo ''; esc_html_e( 'Export', 'booking' ); echo ' (CODE)'; ?></h4>
719 <textarea id="wpbc_bfb__content_form_output"readonly="readonly"></textarea>
720 <div style="margin-top: 8px;">
721 <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>
722 </div>
723 </div>
724 </div>
725
726 </div>
727
728 </div>
729 </div>
730 <?php } ?>
731
732 <!-- Preview Section Content tab -->
733 <div class="wpbc_bfb__tab_section wpbc_bfb__tab_section__preview_tab wpbc_bfb__top_tab_section wpbc_bfb__top_tab_section__preview_tab"
734 <?php echo WPBC_BFB_UI_Top_Tabs::get_panel_hidden_attr( 'preview_tab', $active_tab_id ); /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>>
735 <?php wpbc_bfb_render_preview_panel(); ?>
736 </div>
737 </div>
738 <?php
739
740 // == Hidden Templates for - Booking Actions ==
741 do_action( 'wpbc_hook_bfb_template__hidden_templates' );
742
743 do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking_builder_booking_form' );
744 }
745 }
746
747 add_action( 'wpbc_menu_created', array( new WPBC_Page_Builder_Booking_Form(), '__construct' ) ); // Executed after creation of Menu.
748
749
750 // == Temporary Migrate Functionality ==================================================================================
751
752 /**
753 * Disable showing Legacy "WP Booking Calendar > Settings > Booking Form > Booking Form Fields page" if enabled BFB.
754 *
755 * @param bool $is_show - 'usually' - true.
756 * @param string $page_tag - can be 'wpbc-settings'.
757 * @param string $active_page_tab - can be 'form'.
758 * @param string $active_page_subtab - can be 'booking_form_fields'.
759 *
760 * @return false|mixed
761 */
762 function wpbc_form_fields__check__showing_page( $is_show, $page_tag, $active_page_tab, $active_page_subtab ) {
763
764 if ( ( 'form' === $active_page_tab ) && ( 'wpbc-settings' === $page_tag ) && ( WPBC_Frontend_Settings::is_bfb_enabled( null ) ) ) {
765 $is_show = false;
766 }
767
768 return $is_show;
769 }
770 // 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'.
771 add_filter( 'wpbc_before_showing_settings_page_is_show_page', 'wpbc_form_fields__check__showing_page', 20, 4 );
772
773
774 /**
775 * Unset Form Menu in vertical left menu widget. - unset legacy form builder, if enabled BFB.
776 *
777 * @param array $nav_tabs - array of menus.
778 * @param string $this_page - current selected page.
779 *
780 * @return mixed
781 */
782 function wpbc_form_fields__check__plugin_menu_structure( $nav_tabs, $this_page ) {
783
784 if ( isset( $nav_tabs['wpbc-settings'] ) && isset( $nav_tabs['wpbc-settings']['form'] ) ) {
785 if ( WPBC_Frontend_Settings::is_bfb_enabled( null ) ) {
786 unset( $nav_tabs['wpbc-settings']['form'] );
787 }
788 }
789
790 return $nav_tabs;
791 }
792 add_filter( 'wpbc_plugin_menu_structure_arr', 'wpbc_form_fields__check__plugin_menu_structure', 20, 2 );
793
794
795 /** Trick here to overload default REQUST parameters before page is loading */
796 function wpbc_form_fields__check__define_page_redirect( $page_tag ) {
797
798 // $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'].
799 // Execute it only for WP Booking Calendar > Settings > Booking Form > Booking Form Fields page.
800
801 if ( wpbc_is_settings_form_page() ) {
802 if ( WPBC_Frontend_Settings::is_bfb_enabled( null ) ) {
803 // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
804 wp_redirect( admin_url( "admin.php?page=wpbc-settings&tab=builder_booking_form" ) );
805 // $_REQUEST['tab'] = 'builder_booking_form';
806 // unset( $_REQUEST['subtab'] );
807 // $_SERVER[ 'REQUEST_URI' ] = str_replace( '&subtab=form_options', '', $_SERVER[ 'REQUEST_URI' ] );
808 // $_SERVER[ 'REQUEST_URI' ] = str_replace( 'tab=form', 'tab=builder_booking_form', $_SERVER[ 'REQUEST_URI' ] );
809 }
810 } elseif ( wpbc_is_settings_bfb_page() ) {
811 if ( ! WPBC_Frontend_Settings::is_bfb_enabled( null ) ) {
812 // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
813 wp_redirect( admin_url( "admin.php?page=wpbc-settings&tab=form&subtab=form_options" ) );
814 // $_REQUEST['tab'] = 'form';
815 // $_SERVER[ 'REQUEST_URI' ] = str_replace( 'tab=builder_booking_form', 'tab=form', $_SERVER[ 'REQUEST_URI' ] );
816 }
817 }
818 }
819 // We are set 9 to execute earlier than hook in WPBC_Admin_Menus.
820 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
821