PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
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 2.10.1 All 138 releases
← All changes | includes/Frontend/Form/View/FormViewer.php +59 -119 3.3.12.15.3 View file →
@@ -2,9 +2,8 @@
2 2
3 3 namespace BitCode\BitForm\Frontend\Form\View;
4 4
5 5 use BitCode\BitForm\Admin\Form\Helpers;
6 -use BitCode\BitForm\Core\Util\Translation\TranslationManager;
7 6 use BitCode\BitForm\Frontend\Form\FrontendFormManager;
8 7 use BitCode\BitForm\Frontend\Form\View\Conversational\ConversationalHelpers;
9 8 use BitCode\BitForm\Frontend\Form\View\Conversational\DefaultConversationalTheme;
10 9
@@ -57,49 +56,17 @@
57 56 $honeypodFldName = Helpers::honeypotEncryptedToken("_bitforms_{$this->getFormID()}_{$time}_");
58 57 $honeypotInput = '';
59 58 if (Helpers::property_exists_nested($this->_formContents, 'additional->enabled->honeypot', true)) {
60 59 $honeypotInput =
61 - '
62 - <input type="text" class="d-none" name="b_h_t" value="' . $honeypodFldName . '">
63 - <input type="text" class="d-none" name="' . $honeypodFldName . '" required>
64 - ';
60 + <<<HTMLa
61 + <input type="text" class="d-none" name="b_h_t" value="{$honeypodFldName}">
62 + <input type="text" class="d-none" name="{$honeypodFldName}" required>
63 +HTMLa;
65 64 return $honeypotInput;
66 65 }
67 66 return $honeypotInput;
68 67 }
69 68
70 - /**
71 - * Opt-out markers for HTML-layer translators (Google/GTranslate, TranslatePress)
72 - * when a form disables translation. Empty otherwise, so markup is untouched.
73 - *
74 - * @return array{attrs:string, cls:string}
75 - */
76 - private function noTranslateMarkup()
77 - {
78 - // Pass the row we already hold; otherwise the lookup re-queries form_content per render.
79 - $rawContent = $this->_form->isExist() ? $this->_form->getFieldsContent() : null;
80 - $enabled = TranslationManager::isFormTranslationEnabled($this->getFormID(), $rawContent);
81 - if ($enabled) {
82 - return ['attrs' => '', 'cls' => ''];
83 - }
84 - return ['attrs' => ' translate="no" data-no-translation', 'cls' => ' notranslate'];
85 - }
86 -
87 - /**
88 - * Carries the page language into the AJAX submission so validation and
89 - * confirmation strings match it. Empty when no provider resolves one.
90 - *
91 - * @return string
92 - */
93 - private function languageField()
94 - {
95 - $lang = (string) apply_filters('bitform_current_language', '', $this->getFormID());
96 - if ('' === $lang) {
97 - return '';
98 - }
99 - return '<input type="text" class="d-none" name="bf_lang" value="' . esc_attr($lang) . '">';
100 - }
101 -
102 69 public function setTheme($theme = 'Default')
103 70 {
104 71 $this->_theme = $theme;
105 72 }
@@ -155,9 +122,9 @@
155 122 }
156 123
157 124 public function fields($rowID)
158 125 {
159 - return $this->_fields->{$rowID} ?? null;
126 + return $this->_fields->{$rowID};
160 127 }
161 128
162 129 public function getNestedLayout($rowID)
163 130 {
@@ -180,9 +147,8 @@
180 147 }
181 148
182 149 public function getConversationalView($hasFile, $msg = null)
183 150 {
184 - $noTranslate = $this->noTranslateMarkup();
185 151 $conversationSettings = $this->getFormInfo()->conversationalSettings;
186 152 $this->_themeDetails = new DefaultConversationalTheme($conversationSettings);
187 153 $file_upload_tag = null;
188 154 $restrictionMsg = '';
@@ -212,9 +178,9 @@
212 178 }
213 179 }
214 180 $conversationNavigationHtml = $conversationalHelper->getNavigationView();
215 181
216 - // $confMsg = $this->_form->getSuccessMessageMarkups();
182 + $confMsg = $this->_form->getSuccessMessageMarkups();
217 183 $abandonmentMsg = $this->_form->getFormAbandonmentMessage();
218 184
219 185 // if (!empty($this->_buttons)) {
220 186 // $this->_buttons->name = $formIdentifier;
@@ -222,37 +188,35 @@
222 188 // $subBtn = $this->_themeDetails->getField($this->_buttons, $buttonClass, '');
223 189 // }
224 190
225 191 if (!empty($msg)) {
226 - $restrictionMsg =
227 - '
228 - <div class="' . $this->_form->getAtomicCls("_frm-ovrly-b{$formID}") . '">
229 - <p class="' . $this->_form->getAtomicCls("_frm-ovrly-msg-b{$formID}") . '">
230 - ' . $msg . '
192 + $restrictionMsg = <<<MSG
193 + <div class="{$this->_form->getAtomicCls("_frm-ovrly-b{$formID}")}">
194 + <p class="{$this->_form->getAtomicCls("_frm-ovrly-msg-b{$formID}")}">
195 + $msg
231 196 </p>
232 197 </div>
233 - ';
198 +MSG;
234 199 }
235 200 $formHTML =
236 - '
237 - <div id="' . $formIdentifier . '"' . $noTranslate['attrs'] . ' class="b' . $formID . '-bit-form ' . $this->_form->getAtomicCls("_frm-bg-b{$formID}") . ' bit-form bf-form-wrapper' . $noTranslate['cls'] . '">
238 - ' . $restrictionMsg . '
239 - <form novalidate id="form-' . $formIdentifier . '" class="_frm-bc' . $formID . ' bf-form" ' . $file_upload_tag . ' method=\'post\'>
240 - <input type="text" class="d-none" name="csrf" value="' . $this->_tokens['csrf'] . '">
241 - <input type="text" class="d-none" name="t_identity" value="' . $this->_tokens['t_identity'] . '">
242 - ' . $this->honeypotField() . '
243 - <input type="text" class="d-none" name="bitforms_id" value="bitforms_' . $this->_form->getFormID() . '">
244 - ' . $this->languageField() . '
245 - <div class="bc' . $formID . '-steps-container">
246 - ' . $welcomePageHtml . '
247 - ' . $fieldHtml . '
248 - ' . $conversationNavigationHtml . '
201 + <<<HTMLa
202 + <div id="{$formIdentifier}" class="bit-form {$this->_form->getAtomicCls("_frm-bg-b{$formID}")}">
203 + $restrictionMsg
204 + <form novalidate id="form-{$formIdentifier}" class="_frm-bc{$formID}" $file_upload_tag method='post'>
205 + <input type="text" class="d-none" name="csrf" value="{$this->_tokens['csrf']}">
206 + <input type="text" class="d-none" name="t_identity" value="{$this->_tokens['t_identity']}">
207 + {$this->honeypotField()}
208 + <input type="text" class="d-none" name="bitforms_id" value="bitforms_{$this->_form->getFormID()}">
209 + <div class="bc{$formID}-steps-container">
210 + $welcomePageHtml
211 + $fieldHtml
249 212 </div>
250 213 </form>
251 - <div id=\'bc-form-msg-wrp-' . $formIdentifier . '\' class="bc-form-msg-wrp"></div>
252 - ' . $abandonmentMsg . '
214 + <div id='bc-form-msg-wrp-{$formIdentifier}' class="bc-form-msg-wrp"></div>
215 + $abandonmentMsg
216 + $conversationNavigationHtml
253 217 </div>
254 -';
218 +HTMLa;
255 219
256 220 return $formHTML;
257 221 }
258 222
@@ -257,9 +221,8 @@
257 221 }
258 222
259 223 private function setView($hasFile, $msg)
260 224 {
261 - $noTranslate = $this->noTranslateMarkup();
262 225 $file_upload_tag = null;
263 226 $restrictionMsg = '';
264 227 $formID = $this->_form->getFormID();
265 228 if ($hasFile) {
@@ -279,43 +242,32 @@
279 242 $fieldHtml .= $this->getLayoutHtml($layouts);
280 243 } else {
281 244 $formViewHelper = new FormViewHelper($this->_form, $this->_formContents);
282 245
283 - $fieldHtml .=
284 - '
285 - <div class=\'' . $this->_form->getAtomicCls("_frm-b{$formID}-stp-cntnr") . ' _frm-b-stp-cntnr\'>
286 - ' . $formViewHelper->getStepHeaderHtml() . '
287 - <div class=\'' . $this->_form->getAtomicCls("_frm-b{$formID}-stp-wrpr") . ' _frm-b-stp-wrpr\'>
288 - ' . $formViewHelper->getProgressBarMarkup() . '
289 - <div class=\'' . $this->_form->getAtomicCls("_frm-b{$formID}-stp-cntnt-wrpr") . ' _frm-b-stp-cntnt-wrpr\'>
290 -';
246 + $fieldHtml .= <<<STEPWRPR
247 + <div class='{$this->_form->getAtomicCls("_frm-b{$formID}-stp-cntnr")}'>
248 + {$formViewHelper->getStepHeaderHtml()}
249 + <div class='{$this->_form->getAtomicCls("_frm-b{$formID}-stp-wrpr")}'>
250 + {$formViewHelper->getProgressBarMarkup()}
251 + <div class='{$this->_form->getAtomicCls("_frm-b{$formID}-stp-cntnt-wrpr")}'>
252 +STEPWRPR;
291 253 foreach ($layouts as $key => $lay) {
292 254 $hideOtherSteps = $key > 0 ? 'deactive' : '';
293 255 $step = $key + 1;
294 - $ariaHidden = $key > 0 ? 'aria-hidden="true"' : '';
295 - $fieldHtml .=
296 - '
297 - <div
298 - class="' . $this->_form->getAtomicCls("_frm-b{$formID}-stp-cntnt") . ' _frm-b-stp-cntnt ' . $hideOtherSteps . '"
299 - data-step="' . $step . '"
300 - role="tabpanel"
301 - id="step-' . $formID . '-' . $step . '-panel"
302 - aria-labelledby="step-' . $formID . '-' . $step . '-tab"
303 - ' . $ariaHidden . '
304 - >
305 - <div class="_frm-b' . $formID . ' _frm-b">
306 - ' . $this->getLayoutHtml($lay->layout) . '
256 + $fieldHtml .= <<<HTMLa
257 + <div class="{$this->_form->getAtomicCls("_frm-b{$formID}-stp-cntnt")} $hideOtherSteps" data-step="{$step}">
258 + <div class="_frm-b{$formID}">
259 + {$this->getLayoutHtml($lay->layout)}
307 260 </div>
308 - ' . $formViewHelper->getStepButtonMarkup() . '
261 + {$formViewHelper->getStepButtonMarkup()}
309 262 </div>
310 -';
263 +HTMLa;
311 264 }
312 - $fieldHtml .=
313 - '
265 + $fieldHtml .= <<<CLOSINGTAG
314 266 </div>
315 267 </div>
316 268 </div>
317 -';
269 +CLOSINGTAG;
318 270 }
319 271
320 272 $confMsg = $this->_form->getSuccessMessageMarkups();
321 273 $abandonmentMsg = $this->_form->getFormAbandonmentMessage();
@@ -326,43 +278,31 @@
326 278 $subBtn = $this->_themeDetails->getField($this->_buttons, $buttonClass, '');
327 279 }
328 280
329 281 if (!empty($msg)) {
330 - $restrictionMsg =
331 - '
332 - <div class="' . $this->_form->getAtomicCls("_frm-ovrly-b{$formID}") . '">
333 - <p class="' . $this->_form->getAtomicCls("_frm-ovrly-msg-b{$formID}") . '">
334 - ' . $msg . '
282 + $restrictionMsg = <<<MSG
283 + <div class="{$this->_form->getAtomicCls("_frm-ovrly-b{$formID}")}">
284 + <p class="{$this->_form->getAtomicCls("_frm-ovrly-msg-b{$formID}")}">
285 + $msg
335 286 </p>
336 287 </div>
337 -';
288 +MSG;
338 289 }
339 290 $formHTML =
340 - '
341 - <div id="' . $formIdentifier . '"' . $noTranslate['attrs'] . ' class="b' . $formID . '-bit-form ' . $this->_form->getAtomicCls("_frm-bg-b{$formID}") . ' bit-form bf-form-wrapper' . $noTranslate['cls'] . '">
342 - ' . $restrictionMsg . '
343 - <form novalidate id="form-' . $formIdentifier . '" class="' . $this->_form->getAtomicCls("_frm-b{$formID}") . ' bf-form" ' . $file_upload_tag . ' method=\'post\'>
344 - <input type="text" class="d-none" name="csrf" value="' . $this->_tokens['csrf'] . '">
345 - <input type="text" class="d-none" name="t_identity" value="' . $this->_tokens['t_identity'] . '">
346 - ' . $this->honeypotField() . '
347 - <input type="text" class="d-none" name="bitforms_id" value="bitforms_' . $this->_form->getFormID() . '">
348 - ' . $this->languageField() . '
349 - ' . $fieldHtml . '
291 + <<<HTMLa
292 + <div id="{$formIdentifier}" class="bit-form {$this->_form->getAtomicCls("_frm-bg-b{$formID}")}">
293 + $restrictionMsg
294 + <form novalidate id="form-{$formIdentifier}" class="{$this->_form->getAtomicCls("_frm-b{$formID}")}" $file_upload_tag method='post'>
295 + <input type="text" class="d-none" name="csrf" value="{$this->_tokens['csrf']}">
296 + <input type="text" class="d-none" name="t_identity" value="{$this->_tokens['t_identity']}">
297 + {$this->honeypotField()}
298 + <input type="text" class="d-none" name="bitforms_id" value="bitforms_{$this->_form->getFormID()}">
299 + $fieldHtml
350 300 </form>
351 - ' . $abandonmentMsg . '
352 - <div id=\'bf-form-msg-wrp-' . $formIdentifier . '\'></div>
353 - <!--
354 - Live Region for Screen Reader Announcements (Accessibility)
355 - -->
356 - <div
357 - class="bf-live-region"
358 - role="status"
359 - aria-live="polite"
360 - aria-atomic="true"
361 - style="position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;"
362 - ></div>
363 - ' . $confMsg . '
301 + $abandonmentMsg
302 + <div id='bf-form-msg-wrp-{$formIdentifier}'></div>
303 + $confMsg
364 304 </div>
365 -';
305 +HTMLa;
366 306 return $formHTML;
367 307 }
368 308 }