PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / V3.3.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder vV3.3.2
V3.3.2 3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 All 139 releases
← All changes | includes/Frontend/Form/View/Conversational/Fields/ConversationalInputWrapper.php +178 -88 2.10.0 → V3.3.2 View file →
@@ -14,8 +14,10 @@
14 14
15 15 public function __construct($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
16 16 {
17 17 parent::__construct($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
18 + // Same normalization as parent — this class shadows _fieldData with its own copy.
19 + $field = is_object($field) ? $field : new \stdClass();
18 20 $this->_fieldData = $field;
19 21 $this->_fieldKey = $rowID;
20 22 $this->_error = $error;
21 23 $this->_fieldHelpers = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map);
@@ -25,25 +27,35 @@
25 27 {
26 28 $labelWrapper = !$noLabel ? $this->labelWrapper() : '';
27 29 $helperText = $this->helperText();
28 30 $error = !$noErrMsg ? $this->errorMessages() : '';
29 - $inputWrapper = <<<INPUTWRAPPER
30 - <div
31 - {$this->_fieldHelpers->getCustomAttributes('fld-wrp')}
32 - class="{$this->_fieldHelpers->getConversationalCls('fld-wrp')} {$this->_fieldHelpers->getCustomClasses('fld-wrp')}"
33 - >
31 + $inputWrapper = sprintf(
32 + '<div
33 + %1$s
34 + class="%2$s %3$s"
35 + >
34 36
35 - {$labelWrapper}
37 + %4$s
36 38 <div
37 - {$this->_fieldHelpers->getCustomAttributes('inp-wrp')}
38 - class="{$this->_fieldHelpers->getConversationalCls('inp-wrp')} {$this->_fieldHelpers->getCustomClasses('inp-wrp')}"
39 + %5$s
40 + class="%6$s %7$s"
39 41 >
40 - {$field}
41 - {$helperText}
42 - {$error}
43 - </div>
44 - </div>
45 -INPUTWRAPPER;
42 + %8$s
43 + %9$s
44 + %10$s
45 + </div>
46 + </div>',
47 + $this->_fieldHelpers->getCustomAttributes('fld-wrp'), // 1
48 + $this->_fieldHelpers->getConversationalCls('fld-wrp'), // 2
49 + $this->_fieldHelpers->getCustomClasses('fld-wrp'), // 3
50 + $labelWrapper, // 4
51 + $this->_fieldHelpers->getCustomAttributes('inp-wrp'), // 5
52 + $this->_fieldHelpers->getConversationalCls('inp-wrp'), // 6
53 + $this->_fieldHelpers->getCustomClasses('inp-wrp'), // 7
54 + $field, // 8
55 + $helperText, // 9
56 + $error // 10
57 + );
46 58
47 59 return $inputWrapper;
48 60 }
49 61
@@ -69,36 +81,47 @@
69 81 $_subtitleText = wp_kses_post($this->_fieldHelpers->renderHTMR($replaceToBackSlash));
70 82 }
71 83
72 84 // for pre required icon
85 + // aria-hidden="true" hides the asterisk from screen readers since the input
86 + // already has aria-required="true" which properly announces the required state.
73 87 if (
74 88 $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->req')
75 89 && $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->reqShow', true)
76 90 && $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->reqPos', 'before')
77 91 ) {
78 - $_reqPre = <<<REQPRE
79 - <span
80 - {$this->_fieldHelpers->getCustomAttributes('req-smbl')}
81 - class="{$this->_fieldHelpers->getConversationalCls('req-smbl')} {$this->_fieldHelpers->getCustomClasses('req-smbl')}"
82 - >
83 - *
84 - </span>
85 -REQPRE;
92 + $_reqPre = sprintf(
93 + '<span
94 + %1$s
95 + class="%2$s %3$s"
96 + aria-hidden="true"
97 + >
98 + *
99 + </span>',
100 + $this->_fieldHelpers->getCustomAttributes('req-smbl'),
101 + $this->_fieldHelpers->getConversationalCls('req-smbl'),
102 + $this->_fieldHelpers->getCustomClasses('req-smbl')
103 + );
86 104 }
87 105 // for post required icon
106 + // Same as pre required icon - hide from assistive technology to prevent redundancy.
88 107 if (
89 108 $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->req')
90 109 && $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->reqShow', true)
91 110 && $this->_fieldHelpers->property_exists_nested($this->_fieldData, 'valid->reqPos', 'before', 1)
92 111 ) {
93 - $_reqPost = <<<REQPOST
94 - <span
95 - {$this->_fieldHelpers->getCustomAttributes('req-smbl')}
96 - class="{$this->_fieldHelpers->getConversationalCls('req-smbl')} {$this->_fieldHelpers->getCustomClasses('req-smbl')}"
97 - >
98 - *
99 - </span>
100 -REQPOST;
112 + $_reqPost = sprintf(
113 + '<span
114 + %1$s
115 + class="%2$s %3$s"
116 + aria-hidden="true"
117 + >
118 + *
119 + </span>',
120 + $this->_fieldHelpers->getCustomAttributes('req-smbl'),
121 + $this->_fieldHelpers->getConversationalCls('req-smbl'),
122 + $this->_fieldHelpers->getCustomClasses('req-smbl')
123 + );
101 124 }
102 125
103 126 // for Label
104 127 if (
@@ -107,44 +130,68 @@
107 130 // && $this->_fieldData->valid->hideLbl !== true
108 131 ) {
109 132 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
110 133 $contentCount = count($bfFrontendFormIds);
111 - $_label = <<<LABEL
112 - <label
113 - {$this->_fieldHelpers->getCustomAttributes('lbl')}
114 - class="{$this->_fieldHelpers->getConversationalMultiCls('lbl')} {$this->_fieldHelpers->getCustomClasses('lbl')}"
115 - for="{$this->_fieldKey}-{$contentCount}">
116 - {$_reqPre}
117 - {$_lblPreIcn}
118 - {$_lbl}
119 - {$_lblSufIcn}
120 - {$_reqPost}
121 - </label>
122 -LABEL;
134 + $labelId = $this->_fieldHelpers->getLabelId();
135 + $_label = sprintf(
136 + '<label
137 + id="%1$s"
138 + %2$s
139 + class="%3$s %4$s"
140 + for="%5$s-%6$s">
141 + %7$s
142 + %8$s
143 + %9$s
144 + %10$s
145 + %11$s
146 + </label>',
147 + $labelId, // 1
148 + $this->_fieldHelpers->getCustomAttributes('lbl'), // 2
149 + $this->_fieldHelpers->getConversationalMultiCls('lbl'), // 3
150 + $this->_fieldHelpers->getCustomClasses('lbl'), // 4
151 + $this->_fieldKey, // 5
152 + $contentCount, // 6
153 + $_reqPre, // 7
154 + $_lblPreIcn, // 8
155 + $_lbl, // 9
156 + $_lblSufIcn, // 10
157 + $_reqPost // 11
158 + );
123 159 }
124 160
125 161 // for subtitle
126 162 if (property_exists($this->_fieldData, 'subtitle') && $this->_fieldData->subtitleHide) {
127 - $_subtitle = <<<SUBTITLE
128 - <div
129 - {$this->_fieldHelpers->getCustomAttributes('sub-titl')}
130 - class="{$this->_fieldHelpers->getConversationalMultiCls('sub-titl')} {$this->_fieldHelpers->getCustomClasses('sub-titl')}"
163 + $_subtitle = sprintf(
164 + '<div
165 + %1$s
166 + class="%2$s %3$s"
131 167 >
132 - {$_subtitlePreIcn}
133 - {$_subtitleText}
134 - {$_subtitlePostIcn}
135 - </div>
136 -SUBTITLE;
168 + %4$s
169 + %5$s
170 + %6$s
171 + </div>',
172 + $this->_fieldHelpers->getCustomAttributes('sub-titl'),
173 + $this->_fieldHelpers->getConversationalMultiCls('sub-titl'),
174 + $this->_fieldHelpers->getCustomClasses('sub-titl'),
175 + $_subtitlePreIcn,
176 + $_subtitleText,
177 + $_subtitlePostIcn
178 + );
137 179 }
138 - return <<<LABELWRAPPER
139 - <div
140 - {$this->_fieldHelpers->getCustomAttributes('lbl-wrp')}
141 - class="{$this->_fieldHelpers->getConversationalCls('lbl-wrp')} {$this->_fieldHelpers->getCustomClasses('lbl-wrp')}"
180 + return sprintf(
181 + ' <div
182 + %1$s
183 + class="%2$s %3$s"
142 184 >
143 - {$_label}
144 - {$_subtitle}
145 - </div>
146 -LABELWRAPPER;
185 + %4$s
186 + %5$s
187 + </div>',
188 + $this->_fieldHelpers->getCustomAttributes('lbl-wrp'),
189 + $this->_fieldHelpers->getConversationalCls('lbl-wrp'),
190 + $this->_fieldHelpers->getCustomClasses('lbl-wrp'),
191 + $_label,
192 + $_subtitle
193 + );
147 194 }
148 195
149 196 private function helperText()
150 197 {
@@ -156,18 +203,27 @@
156 203 $_helperTxt = wp_kses_post($this->_fieldHelpers->renderHTMR($this->_fieldData->helperTxt));
157 204 }
158 205
159 206 if (property_exists($this->_fieldData, 'helperTxt') && $this->_fieldData->helperTxt) {
160 - $_helperTxt = <<<HELPERTEXT
161 - <div
162 - {$this->_fieldHelpers->getCustomAttributes('hlp-txt')}
163 - class="{$this->_fieldHelpers->getConversationalMultiCls('hlp-txt')} {$this->_fieldHelpers->getCustomClasses('hlp-txt')}"
164 - >
165 - {$_helperTxtPreIcn}
166 - {$_helperTxt}
167 - {$_helperTxtSufIcn}
168 - </div>
169 -HELPERTEXT;
207 + $helperTextId = $this->_fieldHelpers->getHelperTextId();
208 + $_helperTxt = sprintf(
209 + '<div
210 + id="%1$s"
211 + %2$s
212 + class="%3$s %4$s"
213 + >
214 + %5$s
215 + %6$s
216 + %7$s
217 + </div>',
218 + $helperTextId,
219 + $this->_fieldHelpers->getCustomAttributes('hlp-txt'),
220 + $this->_fieldHelpers->getConversationalMultiCls('hlp-txt'),
221 + $this->_fieldHelpers->getCustomClasses('hlp-txt'),
222 + $_helperTxtPreIcn,
223 + $_helperTxt,
224 + $_helperTxtSufIcn
225 + );
170 226 }
171 227
172 228 // for helper text
173 229 return $_helperTxt;
@@ -184,8 +240,9 @@
184 240 $_error = wp_kses_post($this->_error);
185 241 $_style = 'margin-top: 5px !important; height: 9px !important;';
186 242 }
187 243
244 + $errorId = $this->_fieldHelpers->getErrorId();
188 245 $errMsgStart = '';
189 246 $errMsgEnd = '';
190 247 $msgStyle = "style='display: none !important;'";
191 248 $errMsgAtomicCls = $this->_fieldHelpers->getConversationalMultiCls('err-msg');
@@ -199,32 +256,65 @@
199 256 $errMsgCustomCls = '';
200 257 $errMsgCustomAttr = '';
201 258 }
202 259
203 - return <<<ERRORMESSAGES
204 - <div class='{$this->_fieldHelpers->getConversationalMultiCls('err-wrp')}' style="{$_style}">
205 - <div class='{$this->_fieldHelpers->getConversationalCls('err-inner')}'>
206 - {$errMsgStart}
207 - {$_errorPreIcn}
208 - <div {$this->_fieldHelpers->getCustomAttributes('err-txt')} {$errMsgCustomAttr} class="{$errMsgAtomicCls} {$errMsgCustomCls} {$this->_fieldHelpers->getConversationalMultiCls('err-txt')} {$this->_fieldHelpers->getCustomClasses('err-txt')}" {$msgStyle}>{$_error}</div>
209 - {$_errorSufIcn}
210 - {$errMsgEnd}
211 - </div>
212 - </div>
213 -ERRORMESSAGES;
260 + return sprintf(
261 + '<div class="%1$s" role="alert" aria-atomic="true" aria-live="assertive" style="%2$s">
262 + <div class="%3$s">
263 + %4$s
264 + %5$s
265 + <div id="%6$s" %7$s %8$s class="%9$s %10$s %11$s %12$s " %13$s>
266 + %14$s
267 + </div>
268 + %15$s
269 + %16$s
270 + </div>
271 + </div>',
272 + $this->_fieldHelpers->getConversationalMultiCls('err-wrp'), // 1
273 + $_style, // 2
274 + $this->_fieldHelpers->getConversationalCls('err-inner'), // 3
275 + $errMsgStart, // 4
276 + $_errorPreIcn, // 5
277 + $errorId, // 6
278 + $this->_fieldHelpers->getCustomAttributes('err-txt'), // 7
279 + $errMsgCustomAttr, // 8
280 + $errMsgAtomicCls, // 9
281 + $errMsgCustomCls, // 10
282 + $this->_fieldHelpers->getConversationalMultiCls('err-txt'), // 11
283 + $this->_fieldHelpers->getCustomClasses('err-txt'), // 12
284 + $msgStyle, // 13
285 + $_error, // 14
286 + $_errorSufIcn, // 15
287 + $errMsgEnd // 16
288 + );
214 289 }
215 290
216 291 public function conversationalIcon($icnPropName, $element)
217 292 {
218 293 if ($this->_fieldHelpers->property_exists_nested($this->_fieldData, $icnPropName, '', 1)) {
219 - return <<<ICON
220 -<img
221 - {$this->_fieldHelpers->getCustomAttributes($element)}
222 - class="{$this->_fieldHelpers->getConversationalCls($element)} {$this->_fieldHelpers->getCustomClasses($element)}"
223 - src="{$this->_fieldHelpers->esc_url($this->_fieldData->{$icnPropName})}"
224 - alt=""
225 -/>
226 -ICON;
294 + return sprintf(
295 + '<img
296 + %1$s
297 + class="%2$s %3$s"
298 + src="%4$s"
299 + alt=""
300 + aria-hidden="true"
301 + />
302 + ',
303 + $this->_fieldHelpers->getCustomAttributes($element),
304 + $this->_fieldHelpers->getConversationalCls($element),
305 + $this->_fieldHelpers->getCustomClasses($element),
306 + $this->_fieldHelpers->esc_url($this->_fieldData->{$icnPropName})
307 + );
227 308 }
228 309 return '';
310 + }
311 +
312 + /**
313 + * Get the field helpers instance for external access
314 + * @return ConversationalFieldHelpers
315 + */
316 + public function getFieldHelpers()
317 + {
318 + return $this->_fieldHelpers;
229 319 }
230 320 }