PluginProbe
Booking Calendar / 11.4.2
Booking Calendar v11.4.2
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 / textarea / textarea.php

textarea.php in Booking Calendar 11.4.2, at includes/page-form-builder/field-packs/textarea/textarea.php

159 lines 6.4 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: Textarea Field (Schema-driven)
4 *
5 * Purpose:
6 * - Multi-line text input built on the Schema/Factory inspector (no WP templates).
7 * - Preview is rendered via pure JS renderer class.
8 * - Mirrors the "text" reference pack but adapted for <textarea>.
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; used here to list Textarea in the palette)
14 *
15 * Notes:
16 * - Keep schema defaults in sync with JS get_defaults().
17 *
18 * File: ../includes/page-form-builder/field-packs/textarea/field-textarea.php
19 *
20 * @package Booking Calendar
21 * @author wpdevelop, oplugins
22 * @web-site https://wpbookingcalendar.com/
23 * @email info@wpbookingcalendar.com
24 *
25 * @since 11.0.0
26 * @modified 2025-09-09
27 * @version 1.0.0
28 */
29
30 if ( ! defined( 'ABSPATH' ) ) {
31 exit;
32 }
33
34 /**
35 * Register the "textarea" field pack (Schema-driven inspector).
36 *
37 * @param array $packs Accumulated packs.
38 *
39 * @return array Modified packs with "textarea" field included.
40 */
41 function wpbc_bfb_register_field_packs__field_textarea_schema( $packs ) {
42
43 $packs['textarea'] = array(
44 'kind' => 'field',
45 'type' => 'textarea',
46 'label' => __( 'Textarea', 'booking' ),
47 'icon' => 'wpbc_icn_notes', // Reuse icon; adjust if you have a specific textarea icon.
48 'usage_key' => 'textarea',
49
50 // === Schema: coercion/validation + defaults for Inspector/serialization ===.
51 'schema' => array(
52 'props' => array(
53 'label' => array( 'type' => 'string', 'default' => __( 'Textarea', 'booking' ) ),
54 'name' => array( 'type' => 'string', 'default' => '' ),
55 'html_id' => array( 'type' => 'string', 'default' => '' ),
56 'placeholder' => array( 'type' => 'string', 'default' => '' ),
57 'required' => array( 'type' => 'boolean', 'default' => false ),
58 //'minlength' => array( 'type' => 'number', 'default' => null, 'min' => 0 ),
59 //'maxlength' => array( 'type' => 'number', 'default' => null, 'min' => 0 ),
60 'rows' => array( 'type' => 'number', 'default' => 4, 'min' => 1, 'max' => 50 ),
61 'cssclass' => array( 'type' => 'string', 'default' => '' ),
62 'help' => array( 'type' => 'string', 'default' => '' ),
63 'default_value' => array( 'type' => 'string', 'default' => '' ),
64 // Let the Min-Width guard keep columns usable
65 'min_width' => array( 'type' => 'string', 'default' => '260px' ),
66 ),
67 ),
68
69 // === Inspector UI (Factory-driven; no WP templates here) ===.
70 'inspector_ui' => array(
71 'title' => __( 'Textarea', 'booking' ),
72 'description' => __( 'Configure a multi-line text input.', 'booking' ),
73 'header_variant' => 'toolbar',
74 'header_actions' => array( 'deselect', 'scrollto', 'move-up', 'move-down', 'duplicate', 'delete' ),
75 'groups' => array(
76 array(
77 'key' => 'basic',
78 'label' => __( 'Basic', 'booking' ),
79 'open' => true,
80 'controls' => array(
81 array( 'type' => 'text', 'key' => 'label', 'label' => __( 'Label', 'booking' ) ),
82 array( 'type' => 'text', 'key' => 'name', 'label' => __( 'Name', 'booking' ) ),
83 array( 'type' => 'text', 'key' => 'placeholder', 'label' => __( 'Placeholder', 'booking' ) ),
84 array( 'type' => 'checkbox', 'key' => 'required', 'label' => __( 'Required', 'booking' ) ),
85 array( 'type' => 'textarea', 'key' => 'default_value', 'label' => __( 'Default value', 'booking' ), 'rows' => 3 ),
86 array( 'type' => 'textarea', 'key' => 'help', 'label' => __( 'Help text', 'booking' ), 'rows' => 3 ),
87 ),
88 ),
89
90 // // Validation
91 // array(
92 // 'key' => 'validation',
93 // 'label' => __( 'Validation', 'booking' ),
94 // 'controls' => array(
95 // array( 'type' => 'number', 'key' => 'minlength', 'label' => __( 'Min length', 'booking' ) ),
96 // array( 'type' => 'number', 'key' => 'maxlength', 'label' => __( 'Max length', 'booking' ) ),
97 // ),
98 // ),
99
100 // Appearance
101 array(
102 'key' => 'appearance',
103 'label' => __( 'Appearance', 'booking' ),
104 'controls' => array(
105 array( 'type' => 'text', 'key' => 'cssclass', 'label' => __( 'CSS class', 'booking' ) ),
106 array( 'type' => 'text', 'key' => 'html_id', 'label' => __( 'HTML ID', 'booking' ) ),
107 // array( 'type' => 'text', 'key' => 'min_width', 'label' => __( 'Min width (e.g. 260px / 20rem / 40%)', 'booking' ) ),
108 array( 'type' => 'number', 'key' => 'rows', 'label' => __( 'Rows', 'booking' ), 'min' => 1, 'max' => 50 ),
109 ),
110 ),
111 ),
112 ),
113 );
114
115 return $packs;
116 }
117 add_filter( 'wpbc_bfb_register_field_packs', 'wpbc_bfb_register_field_packs__field_textarea_schema' );
118
119 /**
120 * Enqueue the Textarea field pack JS for the Builder page.
121 *
122 * @param string $page Current admin page slug.
123 *
124 * @return void
125 */
126 function wpbc_bfb_enqueue__field_textarea_schema_js( $page ) {
127
128 wp_enqueue_script( 'wpbc-bfb_field_textarea_schema', wpbc_plugin_url( '/includes/page-form-builder/field-packs/textarea/_out/textarea.js' ), array( 'wpbc-bfb' ), WP_BK_VERSION_NUM, true );
129 }
130 add_action( 'wpbc_enqueue_js_field_pack', 'wpbc_bfb_enqueue__field_textarea_schema_js', 10, 1 );
131
132 /**
133 * (Optional) Register the "Textarea" palette item in "general/bottom".
134 *
135 * @param string $group Palette group: 'general' | 'advanced' | ...
136 * @param string $position Position: 'top' | 'bottom'
137 *
138 * @return void
139 */
140 function wpbc_bfb_palette_register_items__textarea_schema( $group, $position ) {
141
142 if ( 'standard' !== $group || 'bottom' !== $position ) {
143 return;
144 }
145 ?>
146 <li class="wpbc_bfb__field"
147 data-id="textarea"
148 data-type="textarea"
149 data-usage_key="textarea"
150 data-min_width="260px"
151 data-label="<?php echo esc_attr( __( 'Textarea', 'booking' ) ); ?>">
152 <i class="menu_icon icon-1x wpbc-bi-textarea-resize"></i>
153 <span class="wpbc_bfb__field-label"><?php echo esc_html( __( 'Textarea', 'booking' ) ); ?></span>
154 <span class="wpbc_bfb__field-type">textarea</span>
155 </li>
156 <?php
157 }
158 add_action( 'wpbc_bfb_palette_register_items', 'wpbc_bfb_palette_register_items__textarea_schema', 10, 2 );
159