PluginProbe
Booking Calendar / 11.4
Booking Calendar v11.4
11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 All 204 releases
booking / includes / page-form-builder / field-packs / submit / submit.php

submit.php in Booking Calendar 11.4, at includes/page-form-builder/field-packs/submit/submit.php

141 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPBC BFB Pack: Submit Button (Schema-driven, Factory Inspector)
4 *
5 * Purpose:
6 * - Follow the same creation rules as the "Text Field (Schema-driven Reference)" pack.
7 * - No WP templates for Inspector; preview is rendered by a pure JS renderer class.
8 * - Keep schema defaults in sync with JS get_defaults().
9 *
10 * Contracts Used:
11 * - Filter: wpbc_bfb_register_field_packs
12 * - Action: wpbc_enqueue_js_field_pack
13 * - Action: wpbc_bfb_palette_register_items (optional palette registration)
14 *
15 * File: ../includes/page-form-builder/field-packs/submit/field-submit.php
16 *
17 * @package Booking Calendar
18 * @author wpdevelop, oplugins
19 * @since 11.0.0
20 * @modified 2025-09-13
21 * @version 1.0.0
22 */
23
24 if ( ! defined( 'ABSPATH' ) ) {
25 exit;
26 }
27
28 /**
29 * Register the "submit" field pack (Schema-driven Inspector).
30 *
31 * @param array $packs Accumulated packs.
32 *
33 * @return array Modified packs with "submit" field included.
34 */
35 function wpbc_bfb_register_field_packs__field_submit_schema( $packs ) {
36
37 $packs['submit'] = array(
38 'kind' => 'field',
39 'type' => 'submit',
40 'label' => __( 'Submit Button', 'booking' ),
41 'icon' => 'wpbc_icn_check_circle',
42 'usage_key' => 'submit',
43
44 // === Schema: coercion/validation + defaults for Inspector/serialization ===
45 'schema' => array(
46 'props' => array(
47 'label' => array( 'type' => 'string', 'default' => __( 'Send', 'booking' ) ),
48 'name' => array( 'type' => 'string', 'default' => '' ),
49 'html_id' => array( 'type' => 'string', 'default' => '' ),
50 'cssclass' => array( 'type' => 'string', 'default' => 'wpbc_bfb__btn wpbc_bfb__btn--primary' ),
51 'help' => array( 'type' => 'string', 'default' => '' ),
52 ),
53 ),
54
55 // === Inspector UI (Factory-driven; no WP templates here) ===
56 'inspector_ui' => array(
57 'title' => __( 'Submit Button', 'booking' ),
58 'description' => __( 'Configure the submit button appearance and attributes.', 'booking' ),
59 'header_variant' => 'toolbar',
60 'header_actions' => array( 'deselect', 'scrollto', 'move-up', 'move-down', 'duplicate', 'delete' ),
61 'groups' => array(
62 array(
63 'key' => 'basic',
64 'label' => __( 'Basic', 'booking' ),
65 'open' => true,
66 'controls' => array(
67 array( 'type' => 'text', 'key' => 'label', 'label' => __( 'Label', 'booking' ) ),
68 // array( 'type' => 'text', 'key' => 'name', 'label' => __( 'Name', 'booking' ) ),
69 array(
70 'type' => 'textarea',
71 'key' => 'help',
72 'label' => __( 'Help text', 'booking' ),
73 'rows' => 3,
74 ),
75 ),
76 ),
77 array(
78 'key' => 'appearance',
79 'label' => __( 'Advanced', 'booking' ),
80 'controls' => array(
81 array( 'type' => 'text', 'key' => 'cssclass', 'label' => __( 'CSS class', 'booking' ) ),
82 array( 'type' => 'text', 'key' => 'html_id', 'label' => __( 'HTML ID', 'booking' ) ),
83 ),
84 ),
85 ),
86 ),
87
88 // No templates_printer for Schema-driven variant.
89 );
90
91 return $packs;
92 }
93 add_filter( 'wpbc_bfb_register_field_packs', 'wpbc_bfb_register_field_packs__field_submit_schema' );
94
95
96 /**
97 * Enqueue the Submit field pack JS for the Builder page.
98 *
99 * This hook is fired only on the Builder page (gated by is_builder_by_request()).
100 *
101 * @param string $page Current admin page slug.
102 *
103 * @return void
104 */
105 function wpbc_bfb_enqueue__field_submit_schema_js( $page ) {
106
107 wp_enqueue_script( 'wpbc-bfb_field_submit_schema', wpbc_plugin_url( '/includes/page-form-builder/field-packs/submit/_out/submit.js' ), array( 'wpbc-bfb' ), WP_BK_VERSION_NUM, true );
108 }
109 add_action( 'wpbc_enqueue_js_field_pack', 'wpbc_bfb_enqueue__field_submit_schema_js', 10, 1 );
110
111
112 /**
113 * (Optional) Register the "Submit" palette item in "general/bottom".
114 *
115 * If your palette auto-builds from packs, you can remove this.
116 *
117 * @param string $group Palette group: 'general' | 'advanced' | ...
118 * @param string $position Position: 'top' | 'bottom'
119 *
120 * @return void
121 */
122 function wpbc_bfb_palette_register_items__submit_schema( $group, $position ) {
123
124 if ( 'essentials' !== $group || 'bottom' !== $position ) {
125 return;
126 }
127 ?>
128 <li class="wpbc_bfb__field"
129 data-id="submit"
130 data-type="submit"
131 data-usage_key="submit"
132 data-usagenumber="1"
133 data-label="<?php echo esc_attr( __( 'Send', 'booking' ) ); ?>">
134 <i class="menu_icon icon-1x wpbc-bi-check2-circle"></i>
135 <span class="wpbc_bfb__field-label"><?php echo esc_html( __( 'Submit', 'booking' ) ); ?></span>
136 <span class="wpbc_bfb__field-type">submit</span>
137 </li>
138 <?php
139 }
140 add_action( 'wpbc_bfb_palette_register_items', 'wpbc_bfb_palette_register_items__submit_schema', 10, 2 );
141