PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.17.6
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.17.6
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 2.10.2 All 137 releases
bit-form / includes / Admin / Form / FrontEndScriptGenerator.php

FrontEndScriptGenerator.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.17.6, at includes/Admin/Form/FrontEndScriptGenerator.php

648 lines 22.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Admin\Form;
4
5 use BitCode\BitForm\Admin\Form\InitJs\Paypal;
6 use BitCode\BitForm\Admin\Form\InitJs\Razorpay;
7 use BitCode\BitForm\Admin\Form\InitJs\Recaptcha;
8 use BitCode\BitForm\Admin\Form\InitJs\RecaptchaV3;
9 use BitCode\BitForm\Admin\Form\InitJs\ScriptLoader;
10 use BitCode\BitForm\Admin\Form\InitJs\Stripe;
11 use BitCode\BitForm\Admin\Form\InitJs\Turnstile;
12 use BitCode\BitForm\Core\Util\FileHandler;
13 use BitCode\BitForm\Core\Util\Log;
14 use BitCode\BitForm\Core\Util\Utilities;
15 use BitCode\BitForm\Core\WorkFlow\WorkFlowHandler;
16 use BitCode\BitFormPro\Admin\FormSettings\FormAbandonment;
17 use WP_Error;
18
19 class FrontEndScriptGenerator
20 {
21 private $_scriptAddedFlags;
22 private $_fields;
23 private $_formContents;
24 private $_jsFilesNeeded;
25 private $_loadedScriptsList;
26 private $_validationJsFilesNeeded;
27
28 public function __construct()
29 {
30 $this->_scriptAddedFlags = [];
31 $this->_fields = [];
32 $this->_jsFilesNeeded = [];
33 $this->_loadedScriptsList = [];
34 $this->_validationJsFilesNeeded = ScriptFilePriorityManager::validationAndOtherScriptFile();
35 }
36
37 private static function generateBfGlobalObjJS($contentIds = [])
38 {
39 $contentidArray = wp_json_encode($contentIds);
40 return <<<GLOBALOBJ
41 if(!window.bf_globals){ window.bf_globals = {};}
42 $contentidArray.forEach(function(contentId){
43 const form = document.getElementById(contentId);
44 if(!form){
45 delete window.bf_globals[contentId];
46 return;
47 }
48 if(!window.bf_globals[contentId]){
49 window.bf_globals[contentId] = {inits: {}, contentId: contentId};
50 }else{
51 window.bf_globals[contentId].inits = {};
52 window.bf_globals[contentId].contentId = contentId;
53 }
54
55 });
56 GLOBALOBJ;
57 }
58
59 private static function isValidationNeeded($fldData)
60 {
61 $validationsToCheck = ['valid->req', 'valid->regexr', 'mn', 'mx', 'opt', 'err->invalid->show'];
62 foreach ($validationsToCheck as $property) {
63 $needValidation = Helpers::property_exists_nested($fldData, $property);
64 if ($needValidation) {
65 return true;
66 }
67 }
68 return false;
69 }
70
71 public function generateJsFile($formContents, $fields, $contentIds, $postId, $formIDs = null, $preview = 'classic')
72 {
73 add_option('bitforms_frontend_js_generating', true);
74 $this->_formContents = $formContents;
75 $this->_fields = $fields;
76
77 $this->appendJs(self::generateBfGlobalObjJS($contentIds), $postId, $preview, 'w');
78 $this->_jsFilesNeeded = ScriptFilePriorityManager::jsFile();
79
80 // helper js files for whole form
81 foreach ($this->_jsFilesNeeded['helperScript'] as $jsFile) {
82 $this->addScriptInLoadedScriptsList($jsFile);
83 }
84
85 // for add validation js files
86 $this->jsValidationNeededFile();
87
88 // js files for all fields
89 $this->jsFieldsNeededFile();
90
91 // for frontend helper js files
92 $this->jsFrontendScript();
93
94 // for hidden Field when cache plugin on
95 $this->jsHiddenFieldScript();
96
97 // for form abandonment scripts
98 $this->jsFormAbandonmentScripts();
99
100 // multi step form scripts
101 $this->multiStepFormScripts();
102
103 // conversational form scripts
104 $this->conversationalFormScripts();
105
106 //⚠👆 every script file generate method call before this method
107 $this->appendJs($this->getScript(), $postId, $preview);
108 $this->appendJs($this->generateFieldConfigsJs($contentIds), $postId, $preview);
109 // init all js events and functions at last
110 $this->appendJs(self::getFileFromAssetsJs('bitform-init.min.js'), $postId, $preview);
111 if (defined('ELEMENTOR_PRO_VERSION')) {
112 $this->appendJs(self::getFileFromAssetsJs('bitform-elementor.min.js'), $postId, $preview);
113 }
114
115 // for js file minification
116 $this->appendJs(self::getCustomJsCodes($contentIds), $postId, $preview);
117 delete_option('bitforms_frontend_js_generating');
118 return true;
119 }
120
121 private function multiStepFormScripts()
122 {
123 foreach ($this->_formContents as $formContent) {
124 $layout = $formContent->layout;
125 if (is_array($layout) && count($layout) > 1) {
126 $files = ScriptFilePriorityManager::multiStepFiles();
127 foreach ($files as $file) {
128 $this->addScriptInLoadedScriptsList($file);
129 }
130 }
131 }
132 }
133
134 private function conversationalFormScripts()
135 {
136 foreach ($this->_formContents as $formContent) {
137 if (!empty($formContent->formInfo->conversationalSettings) && $formContent->formInfo->conversationalSettings->enable) {
138 $files = ScriptFilePriorityManager::conversationalFormFiles();
139 foreach ($files as $file) {
140 $this->addScriptInLoadedScriptsList($file);
141 }
142 }
143 }
144 }
145
146 private function jsFormAbandonmentScripts()
147 {
148 if (!Utilities::isPro() || !class_exists('\BitCode\BitFormPro\Admin\FormSettings\FormAbandonment')) {
149 return;
150 }
151 // check if any of the form has form abandonment enabled
152 $allFiles = [];
153 foreach ($this->_formContents as $formContent) {
154 $formAbandonmentSettings = FormAbandonment::getFormAbandonmentSettings($formContent->formId);
155 if (!empty($formAbandonmentSettings->saveFormDraft)) {
156 $neededFiles = ScriptFilePriorityManager::formAbandonmentNeededFiles('autoSave');
157 $allFiles = array_merge($allFiles, $neededFiles);
158 break;
159 }
160
161 $workflowHandler = new WorkFlowHandler($formContent->formId);
162 $allWorkflows = $workflowHandler->getAllworkFlow();
163 foreach ($allWorkflows as $workflow) {
164 foreach ($workflow['conditions'] as $cond) {
165 if (!empty($cond->actions) && !empty($cond->actions->fields)) {
166 foreach ($cond->actions->fields as $fldAction) {
167 if (empty($fldAction->field) || empty($fldAction->action)) {
168 continue;
169 }
170 if ('_bf_form' === $fldAction->field && 'save_draft' === $fldAction->action) {
171 $neededFiles = ScriptFilePriorityManager::formAbandonmentNeededFiles();
172 $allFiles = array_merge($allFiles, $neededFiles);
173 }
174 }
175 }
176 }
177 }
178 }
179 if (isset($this->_fields['button'])) {
180 foreach ($this->_fields['button'] as $button) {
181 if ('save-draft' === $button['field']->btnTyp) {
182 $neededFiles = ScriptFilePriorityManager::formAbandonmentNeededFiles();
183 $allFiles = array_merge($allFiles, $neededFiles);
184 break;
185 }
186 }
187 }
188 //
189 if (empty($allFiles)) {
190 return;
191 }
192 foreach ($allFiles as $jsFile) {
193 $this->addScriptInLoadedScriptsList($jsFile);
194 }
195 }
196
197 private function appendJs($script, $postId, $previewMode, $mode = 'a')
198 {
199 $fileName = '';
200 $path = '';
201
202 if ('conversational' === $previewMode) {
203 $fileName = "bitform-conversational-{$postId}.js";
204 $path = 'form-scripts';
205 } elseif ('preview' === $previewMode) {
206 $fileName = "preview-{$postId}.js";
207 $path = 'form-scripts';
208 } else {
209 $fileName = "bitform-js-$postId.js";
210 $path = "form-scripts/{$postId}";
211 }
212 Helpers::saveFile($path, $fileName, Helpers::minifyJs($script), $mode);
213 }
214
215 private function getScript()
216 {
217 usort($this->_loadedScriptsList, function ($a, $b) {
218 return $a['priority'] - $b['priority'];
219 });
220
221 $script = '';
222 foreach ($this->_loadedScriptsList as $scriptFileArr) {
223 $fileNam = $scriptFileArr['filename'];
224 if (!isset($scriptFileArr['scriptTyp']) || 'script' === $scriptFileArr['scriptTyp']) {
225 if (self::getFileFromAssetsJs($fileNam)) {
226 $script .= self::getFileFromAssetsJs($fileNam);
227 continue;
228 }
229 continue;
230 }
231 if ('custom' === $scriptFileArr['scriptTyp']) {
232 $fileInstance = $scriptFileArr['source'] . $fileNam;
233 if (!class_exists($fileInstance)) {
234 continue;
235 } // when class not found, skip load script
236 $script .= $fileInstance::init($scriptFileArr['fk'], $scriptFileArr['field'], $scriptFileArr['contentId']);
237 }
238 }
239 return $script;
240 }
241
242 private function jsValidationNeededFile()
243 {
244 foreach ($this->_fields as $flds) {
245 foreach ($flds as $fld) {
246 $fldData = $fld['field'];
247 // for validation js files
248 if (self::isValidationNeeded($fldData)) {
249 $validation = $this->_validationJsFilesNeeded['validation'];
250 $this->addScriptInLoadedScriptsList($validation);
251 }
252 // for required
253 if (Helpers::property_exists_nested($fldData, 'valid->req')) {
254 $fileArr = $this->_validationJsFilesNeeded['requiredFldValidation'];
255 $this->addScriptInLoadedScriptsList($fileArr);
256 }
257 // for regex
258 if (Helpers::property_exists_nested($fldData, 'valid->regexr')) {
259 $patternFile = $this->_validationJsFilesNeeded['generateBackslashPattern'];
260 $rgx = $this->_validationJsFilesNeeded['regexPatternValidation'];
261 $this->addScriptInLoadedScriptsList($patternFile);
262 $this->addScriptInLoadedScriptsList($rgx);
263 }
264
265 $validationScriptFileMapping = ScriptFilePriorityManager::validationScriptFileMapping($fldData->typ);
266 if ($validationScriptFileMapping) {
267 foreach ($validationScriptFileMapping as $key => $value) {
268 foreach ($value['paths'] as $path) {
269 if (Helpers::property_exists_nested($fldData, $path)) {
270 $file = $this->_validationJsFilesNeeded[$key];
271 $this->addScriptInLoadedScriptsList($file);
272 }
273 }
274 if (isset($value['dependencies'])) {
275 foreach ($value['dependencies'] as $dependency) {
276 $dependencyFile = $this->_validationJsFilesNeeded[$dependency];
277 $this->addScriptInLoadedScriptsList($dependencyFile);
278 }
279 }
280 }
281 }
282 }
283 }
284 }
285
286 private function jsFieldsNeededFile()
287 {
288 foreach ($this->_fields as $typ => $flds) {
289 if (!array_key_exists($typ, $this->_jsFilesNeeded)) {
290 continue;
291 }
292 $fldScriptArr = $this->_jsFilesNeeded[$typ];
293
294 foreach ($flds as $fld) {
295 if ('advanced-file-up' === $typ) {
296 $configs = $fld['field']->config;
297 foreach ($configs as $configKey => $config) {
298 if ($configs->$configKey) {
299 $filepondPlugin = ScriptFilePriorityManager::filePondPlugins($configKey);
300 if ($filepondPlugin) {
301 $this->addScriptInLoadedScriptsList($filepondPlugin);
302 }
303 }
304 }
305 }
306 foreach ($fldScriptArr as $scriptFile) {
307 if (!isset($scriptFile['scriptTyp'])) {
308 $this->addScriptInLoadedScriptsList($scriptFile);
309 continue;
310 }
311 if ('custom' === $scriptFile['scriptTyp'] && Helpers::property_exists_nested($fld['field'], $scriptFile['path'], true)) {
312 $scriptFile['field'] = $fld['field'];
313 $scriptFile['fk'] = $fld['fk'];
314 $scriptFile['contentId'] = $fld['contentId'];
315 $this->addScriptInLoadedScriptsList($scriptFile);
316 }
317 }
318 }
319 }
320 }
321
322 private static function getCustomJsCodes($contentIds = [])
323 {
324 $script = 'let bfContentId = "", bfSlNo = "1", bfVars= "";';
325 foreach ($contentIds as $contentId) {
326 $contentIdArr = explode('_', $contentId);
327 $jsCode = self::getCustomCodes($contentIdArr[1])['JavaScript'];
328 $bfSlNo = array_key_exists(3, $contentIdArr) ? $contentIdArr[3] : '1';
329 if (!empty($jsCode)) {
330 $script .= " if(bfSelect('#{$contentId}')){ bfContentId = '{$contentId}'; bfSlNo = '{$bfSlNo}'; bfVars = window.bf_globals.{$contentId}.smartTags; {$jsCode}}";
331 }
332 }
333
334 return $script;
335 }
336
337 private static function getFileFromAssetsJs($fileName)
338 {
339 $sourceJsFile = BITFORMS_PLUGIN_DIR_PATH . 'assets' . DIRECTORY_SEPARATOR . $fileName;
340 if (file_exists($sourceJsFile)) {
341 return file_get_contents($sourceJsFile);
342 }
343 Log::debug_log('file not found: ' . $fileName);
344 return false;
345 }
346
347 public static function saveCssFile($formId, $atomicCssText)
348 {
349 $path = 'form-styles';
350 $fileName = "bitform-$formId.css";
351 if (!isset($formId) || '' === $formId) {
352 return new WP_Error('missing_form_id', __('Error Occurred, Please Reload', 'bit-form'));
353 }
354 return Helpers::saveFile($path, $fileName, $atomicCssText, 'w');
355 }
356
357 public static function customCodeFile($formId, $customCodes)
358 {
359 // for js file
360 $path = 'form-scripts';
361 $fileName = "bitform-custom-$formId.js";
362 self::customCodeFileSaveOrDelete($customCodes->JavaScript, $path, $fileName);
363
364 // for css file
365 $path = 'form-styles';
366 $fileName = "bitform-custom-$formId.css";
367 self::customCodeFileSaveOrDelete($customCodes->CSS, $path, $fileName);
368
369 return true;
370 }
371
372 public static function customCodeFileSaveOrDelete($script, $path, $fileName)
373 {
374 if ($script) {
375 Helpers::saveFile($path, $fileName, $script, 'w');
376 } else {
377 $uploadPath = "$path/$fileName";
378 $uploadFilePath = Helpers::generatePathDirOrFile($uploadPath);
379 FileHandler::deleteIsFileExists($uploadFilePath);
380 }
381 return true;
382 }
383
384 public static function getCustomCodes($formId)
385 {
386 $customCodes = ['JavaScript' => '', 'CSS' => ''];
387 $customJsPath = Helpers::generatePathDirOrFile("form-scripts/bitform-custom-$formId.js");
388 $customCodes['JavaScript'] = Helpers::fileRead($customJsPath);
389
390 $customCSSPath = Helpers::generatePathDirOrFile("form-styles/bitform-custom-$formId.css");
391 $customCodes['CSS'] = Helpers::fileRead($customCSSPath);
392
393 return $customCodes;
394 }
395
396 private $fldContainersByType = [
397 'select' => '.__$fk__-dpd-fld-wrp',
398 'country' => '.__$fk__-country-fld-wrp',
399 'currency' => '.__$fk__-currency-fld-wrp',
400 'phone-number' => '.__$fk__-phone-fld-wrp',
401 'file-up' => '.__$fk__-file-up-wrpr',
402 'advanced-file-up' => '#filepond-__$fk__-container',
403 'paypal' => '.__$fk__-paypal-wrp',
404 'razorpay' => '.__$fk__-razorpay-wrp',
405 'recaptcha' => '.__$fk__-recaptcha-wrp',
406 'stripe' => '.__$fk__-stripe-fld',
407 'mollie' => '.__$fk__-mollie-wrp',
408 'repeater' => '.__$fk__-rpt-fld-wrp',
409 'signature' => '.__$fk__-inp-fld-wrp',
410 'rating' => '.__$fk__-inp-fld-wrp',
411 ];
412
413 private function generateFieldConfigsJs()
414 {
415 $customFlds = ['select', 'country', 'currency', 'phone-number', 'file-up', 'advanced-file-up', 'paypal', 'razorpay', 'stripe', 'mollie', 'recaptcha', 'repeater', 'signature', 'rating', 'turnstile'];
416 $allFieldTypes = array_keys($this->_fields);
417 $customFldsInForms = array_intersect($allFieldTypes, $customFlds);
418 $formContents = $this->_formContents;
419 $recaptchaV3Enabled = false;
420 foreach ($formContents as $content) {
421 if (isset($content->additional->enabled->recaptchav3) && $content->additional->enabled->recaptchav3) {
422 $recaptchaV3Enabled = true;
423 break;
424 }
425 }
426 if (empty($customFldsInForms) && !$recaptchaV3Enabled) {
427 return '';
428 }
429
430 $containers = [];
431 foreach ($customFldsInForms as $customFldTyp) {
432 if (isset($this->fldContainersByType[$customFldTyp])) {
433 $containers[$customFldTyp] = $this->fldContainersByType[$customFldTyp];
434 }
435 }
436
437 $customFldConfigPaths = [];
438
439 foreach ($customFldsInForms as $customFldTyp) {
440 $allConfs = ScriptFilePriorityManager::getAllFldConfs();
441 if (isset($allConfs[$customFldTyp])) {
442 $customFldConfigPaths[$customFldTyp] = $allConfs[$customFldTyp];
443 } else {
444 $customFldConfigPaths[$customFldTyp] = (object) [];
445 }
446 }
447
448 $customFldConfigPaths = wp_json_encode($customFldConfigPaths);
449 $containers = wp_json_encode($containers);
450
451 $scriptLoaderFields = ['paypal', 'razorpay', 'stripe', 'recaptcha', 'turnstile'];
452 $scriptLoadedNeeded = array_intersect($scriptLoaderFields, $customFldsInForms) || $recaptchaV3Enabled;
453 if ($scriptLoadedNeeded) {
454 $scriptLoaderJs = ScriptLoader::init();
455 } else {
456 $scriptLoaderJs = '';
457 }
458
459 if (in_array('paypal', $customFldsInForms)) {
460 $paypalInitJs = Paypal::init();
461 } else {
462 $paypalInitJs = '';
463 }
464
465 if (in_array('razorpay', $customFldsInForms)) {
466 $razorpayInitJs = Razorpay::init();
467 } else {
468 $razorpayInitJs = '';
469 }
470
471 if (in_array('stripe', $customFldsInForms)) {
472 $stripeInitJs = Stripe::init();
473 } else {
474 $stripeInitJs = '';
475 }
476
477 if (in_array('mollie', $customFldsInForms)) {
478 $mollieInitJs = Stripe::init();
479 } else {
480 $mollieInitJs = '';
481 }
482
483 if (in_array('recaptcha', $customFldsInForms)) {
484 $recaptchaInitJs = Recaptcha::init();
485 } else {
486 $recaptchaInitJs = '';
487 }
488
489 if (in_array('turnstile', $customFldsInForms)) {
490 $turnstileInitJs = Turnstile::init();
491 } else {
492 $turnstileInitJs = '';
493 }
494
495 if ($recaptchaV3Enabled) {
496 $recaptchaV3InitJs = RecaptchaV3::init();
497 } else {
498 $recaptchaV3InitJs = '';
499 }
500
501 $script = <<<FIELDCONFIGJS
502 const customFldConfigPaths = $customFldConfigPaths;
503 const fldContainers = $containers;
504
505 $scriptLoaderJs;
506
507 function initAllCustomFlds (formContentId = null) {
508 const allContendIds = formContentId ? [formContentId] : Object.keys(bf_globals);
509 allContendIds.forEach((contentId) => {
510 const contentData = bf_globals[contentId];
511 const flds = bf_globals[contentId]?.fields || {};
512 const fldKeys = Object.keys(flds).reverse();
513 fldKeys.forEach((fldKey) => {
514 const fldData = flds[fldKey];
515 const fldType = fldData.typ;
516 if(fldType === 'paypal') {
517 $paypalInitJs;
518 } else if(fldType === 'razorpay') {
519 $razorpayInitJs;
520 } else if(fldType === 'recaptcha') {
521 $recaptchaInitJs;
522 } else if(fldType === 'turnstile') {
523 $turnstileInitJs;
524 } else if(fldType === 'stripe') {
525 $stripeInitJs;
526 } else if (customFldConfigPaths[fldType]) {
527 contentData.inits[fldKey] = getFldInstance(contentId, fldKey, fldType);
528 }
529 });
530 if(contentData.gRecaptchaVersion === 'v3' && contentData.gRecaptchaSiteKey){
531 $recaptchaV3InitJs;
532 }
533 });
534 };
535 function getFldInstance(contentId, fldKey, fldTyp, nestedSelector = '') {
536 const fldClass = this['bit_'+fldTyp.replace(/-/g, '_')+'_field'];
537 const selector = '#form-'+contentId+' '+nestedSelector+fldContainers[fldTyp].replace("__\$fk__", fldKey);
538 if(!fldClass || !bfSelect(selector)) return;
539 return new fldClass(selector, getFldConf(contentId, fldKey, fldTyp));
540 };
541 function getFldConf(contentId, fieldKey, fldTyp) {
542 const fldData = bf_globals[contentId].fields[fieldKey];
543 const fldConfPaths = Object.entries(customFldConfigPaths[fldTyp]);
544 let fldConf = {};
545 const { formId } = bf_globals[contentId];
546 if (!("config" in customFldConfigPaths[fldTyp]) && "config" in fldData) fldConf = fldData.config;
547 const varData = { contentId, fieldKey, formId };
548 fldConfPaths.forEach(([ confPath, fldPath ]) => {
549 let value = "";
550 if (fldPath.var) value = varData[fldPath.var];
551 if (!value && fldPath.path) {
552 if(Array.isArray(fldPath.path)) {
553 fldPath.path.forEach((path) => {
554 if(!value) value = getDataFromNestedPath(fldData, path);
555 });
556 } else {
557 value = getDataFromNestedPath(fldData, fldPath.path);
558 }
559 }
560 if (!value && fldPath.val) {
561 value = fldPath.val;
562 if(typeof value === 'string') {
563 Object.entries(varData).forEach(([key, val]) => {
564 value = value.replace("__\$"+key+"__", val);
565 });
566 }
567 }
568 fldConf = setDataToNestedPath(fldConf, confPath, value);
569 });
570 return fldConf;
571 };
572 function getDataFromNestedPath(data, key) {
573 const keys = key.split("->");
574 const lastKey = keys.pop();
575 let current = {...data};
576 for (const k of keys) {
577 if (!(k in current)) return null;
578 current = current[k];
579 }
580 return current[lastKey] || null;
581 }
582 function setDataToNestedPath(data, key, value) {
583 const keys = key.split("->");
584 const lastKey = keys.pop();
585 let current = {...data};
586 keys.forEach((k) => {
587 if (!current[k]) current[k] = {};
588 current = current[k];
589 });
590 current[lastKey] = value;
591 return current;
592 }
593 FIELDCONFIGJS;
594
595 return $script;
596 }
597
598 private function addScriptInLoadedScriptsList($fileArr)
599 {
600 $fileName = $fileArr['filename'];
601 if (!in_array($fileName, $this->_scriptAddedFlags)) {
602 $this->_loadedScriptsList[] = $fileArr;
603 $this->_scriptAddedFlags[] = $fileName;
604 }
605 return true;
606 }
607
608 private function jsFrontendScript()
609 {
610 foreach ($this->_formContents as $formContent) {
611 if (Helpers::property_exists_nested($formContent, 'workFlowExist->oninput', true)) {
612 $fileArr = ScriptFilePriorityManager::validationAndOtherScriptFile()['conditionalLogic'];
613 $this->addScriptInLoadedScriptsList($fileArr);
614 $fileArr = ScriptFilePriorityManager::validationAndOtherScriptFile()['resetPlaceholders'];
615 $this->addScriptInLoadedScriptsList($fileArr);
616 $fileArr = ScriptFilePriorityManager::validationAndOtherScriptFile()['validateFocusLost'];
617 $this->addScriptInLoadedScriptsList($fileArr);
618 $fileArr = ScriptFilePriorityManager::frontendScriptFile()['observeElm'];
619 $this->addScriptInLoadedScriptsList($fileArr);
620 }
621 if (Helpers::property_exists_nested($formContent, 'additional->enabled->validateFocusLost', true)) {
622 $fileArr = ScriptFilePriorityManager::validationAndOtherScriptFile()['validateFocusLost'];
623 $this->addScriptInLoadedScriptsList($fileArr);
624 }
625 }
626 }
627
628 private function jsHiddenFieldScript()
629 {
630 $appConfig = get_option('bitform_app_config');
631 if (Helpers::property_exists_nested($appConfig, 'cache_plugin', true)) {
632 $fileArr = ScriptFilePriorityManager::frontendScriptFile()['hidden-token-field'];
633 $this->addScriptInLoadedScriptsList($fileArr);
634 return;
635 }
636 }
637
638 public function dd($data, $exit = false)
639 {
640 echo '+++++++++++++';
641 echo '<pre>';
642 var_dump($data);
643 echo '</pre>';
644 echo '+++++++++++++';
645 $exit ? exit : '';
646 }
647 }
648