PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.9.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.9.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 2.10.2 All 137 releases
← All changes | includes/Admin/Form/FrontEndScriptGenerator.php +186 -155 3.2.02.9.1 View file →
@@ -1,14 +1,19 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Admin\Form;
4 4
5 -if (!defined('ABSPATH')) {
6 - exit;
7 -}
8 -
9 -use BitCode\BitForm\Core\Util\FileHandler;
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;
10 12 use BitCode\BitForm\Core\Util\Log;
13 +use BitCode\BitForm\Core\Util\Utilities;
14 +use BitCode\BitForm\Core\WorkFlow\WorkFlowHandler;
15 +use BitCode\BitFormPro\Admin\FormSettings\FormAbandonment;
11 16 use WP_Error;
12 17
13 18 class FrontEndScriptGenerator
14 19 {
@@ -29,11 +34,12 @@
29 34 }
30 35
31 36 private static function generateBfGlobalObjJS($contentIds = [])
32 37 {
33 - $contentidArray = wp_json_encode($contentIds);
34 - return ' if(!window.bf_globals){ window.bf_globals = {};}
35 - ' . $contentidArray . '.forEach(function(contentId){
38 + $contentidArray = json_encode($contentIds);
39 + return <<<GLOBALOBJ
40 + if(!window.bf_globals){ window.bf_globals = {};}
41 + $contentidArray.forEach(function(contentId){
36 42 const form = document.getElementById(contentId);
37 43 if(!form){
38 44 delete window.bf_globals[contentId];
39 45 return;
@@ -44,14 +50,15 @@
44 50 window.bf_globals[contentId].inits = {};
45 51 window.bf_globals[contentId].contentId = contentId;
46 52 }
47 53
48 - });';
54 + });
55 +GLOBALOBJ;
49 56 }
50 57
51 58 private static function isValidationNeeded($fldData)
52 59 {
53 - $validationsToCheck = ['valid->req', 'valid->regexr', 'mn', 'mx', 'opt', 'err->invalid->show', 'err->notVerified->show'];
60 + $validationsToCheck = ['valid->req', 'valid->regexr', 'mn', 'mx', 'opt', 'err->invalid->show'];
54 61 foreach ($validationsToCheck as $property) {
55 62 $needValidation = Helpers::property_exists_nested($fldData, $property);
56 63 if ($needValidation) {
57 64 return true;
@@ -59,9 +66,9 @@
59 66 }
60 67 return false;
61 68 }
62 69
63 - public function generateJsFile($formContents, $fields, $contentIds, $postId, $formIDs = null, $preview = 'classic')
70 + public function generateJsFile($formContents, $fields, $contentIds, $postId, $formIDs = null, $preview = false)
64 71 {
65 72 add_option('bitforms_frontend_js_generating', true);
66 73 $this->_formContents = $formContents;
67 74 $this->_fields = $fields;
@@ -85,11 +92,8 @@
85 92
86 93 // for hidden Field when cache plugin on
87 94 $this->jsHiddenFieldScript();
88 95
89 - // for recaptcha v3 (form-level setting)
90 - $this->jsRecaptchaV3Scripts();
91 -
92 96 // for form abandonment scripts
93 97 $this->jsFormAbandonmentScripts();
94 98
95 99 // multi step form scripts
@@ -94,11 +98,8 @@
94 98
95 99 // multi step form scripts
96 100 $this->multiStepFormScripts();
97 101
98 - // conversational form scripts
99 - $this->conversationalFormScripts();
100 -
101 102 //⚠👆 every script file generate method call before this method
102 103 $this->appendJs($this->getScript(), $postId, $preview);
103 104 $this->appendJs($this->generateFieldConfigsJs($contentIds), $postId, $preview);
104 105 // init all js events and functions at last
@@ -125,49 +126,64 @@
125 126 }
126 127 }
127 128 }
128 129
129 - private function conversationalFormScripts()
130 + private function jsFormAbandonmentScripts()
130 131 {
132 + if (!Utilities::isPro() || !class_exists('\BitCode\BitFormPro\Admin\FormSettings\FormAbandonment')) {
133 + return;
134 + }
135 + // check if any of the form has form abandonment enabled
136 + $allFiles = [];
131 137 foreach ($this->_formContents as $formContent) {
132 - if (!empty($formContent->formInfo->conversationalSettings) && $formContent->formInfo->conversationalSettings->enable) {
133 - $files = ScriptFilePriorityManager::conversationalFormFiles();
134 - foreach ($files as $file) {
135 - $this->addScriptInLoadedScriptsList($file);
138 + $formAbandonmentSettings = FormAbandonment::getFormAbandonmentSettings($formContent->formId);
139 + if (!empty($formAbandonmentSettings->saveFormDraft)) {
140 + $neededFiles = ScriptFilePriorityManager::formAbandonmentNeededFiles('autoSave');
141 + $allFiles = array_merge($allFiles, $neededFiles);
142 + break;
143 + }
144 +
145 + $workflowHandler = new WorkFlowHandler($formContent->formId);
146 + $allWorkflows = $workflowHandler->getAllworkFlow();
147 + foreach ($allWorkflows as $workflow) {
148 + foreach ($workflow['conditions'] as $cond) {
149 + if (!empty($cond->actions) && !empty($cond->actions->fields)) {
150 + foreach ($cond->actions->fields as $fldAction) {
151 + if (empty($fldAction->field) || empty($fldAction->action)) {
152 + continue;
153 + }
154 + if ('_bf_form' === $fldAction->field && 'save_draft' === $fldAction->action) {
155 + $neededFiles = ScriptFilePriorityManager::formAbandonmentNeededFiles();
156 + $allFiles = array_merge($allFiles, $neededFiles);
157 + }
158 + }
159 + }
136 160 }
137 161 }
138 162 }
139 - }
140 -
141 - private function jsFormAbandonmentScripts()
142 - {
143 - /**
144 - * Add-ons can inject required script files here.
145 - *
146 - * @param array $files Array of file arrays: ['priority' => int, 'filename' => string]
147 - * @param array $formContents
148 - * @param array $fields
149 - */
150 - $files = apply_filters('bitform_form_abandonment_script_files', [], $this->_formContents, $this->_fields);
151 - if (empty($files) || !is_array($files)) {
163 + if (isset($this->_fields['button'])) {
164 + foreach ($this->_fields['button'] as $button) {
165 + if ('save-draft' === $button['field']->btnTyp) {
166 + $neededFiles = ScriptFilePriorityManager::formAbandonmentNeededFiles();
167 + $allFiles = array_merge($allFiles, $neededFiles);
168 + break;
169 + }
170 + }
171 + }
172 + //
173 + if (empty($allFiles)) {
152 174 return;
153 175 }
154 - foreach ($files as $jsFile) {
155 - if (!empty($jsFile['filename']) && !empty($jsFile['priority'])) {
156 - $this->addScriptInLoadedScriptsList($jsFile);
157 - }
176 + foreach ($allFiles as $jsFile) {
177 + $this->addScriptInLoadedScriptsList($jsFile);
158 178 }
159 179 }
160 180
161 - private function appendJs($script, $postId, $previewMode, $mode = 'a')
181 + private function appendJs($script, $postId, $preview, $mode = 'a')
162 182 {
163 183 $fileName = '';
164 184 $path = '';
165 -
166 - if ('conversational' === $previewMode) {
167 - $fileName = "bitform-conversational-{$postId}.js";
168 - $path = 'form-scripts';
169 - } elseif ('preview' === $previewMode) {
185 + if ($preview) {
170 186 $fileName = "preview-{$postId}.js";
171 187 $path = 'form-scripts';
172 188 } else {
173 189 $fileName = "bitform-js-$postId.js";
@@ -184,12 +200,22 @@
184 200
185 201 $script = '';
186 202 foreach ($this->_loadedScriptsList as $scriptFileArr) {
187 203 $fileNam = $scriptFileArr['filename'];
188 - $fileContent = self::getFileFromAssetsJs($fileNam);
189 - if ($fileContent) {
190 - $script .= $fileContent;
204 + if (!isset($scriptFileArr['scriptTyp']) || 'script' === $scriptFileArr['scriptTyp']) {
205 + if (self::getFileFromAssetsJs($fileNam)) {
206 + $script .= self::getFileFromAssetsJs($fileNam);
207 + continue;
208 + }
209 + continue;
191 210 }
211 + if ('custom' === $scriptFileArr['scriptTyp']) {
212 + $fileInstance = $scriptFileArr['source'] . $fileNam;
213 + if (!class_exists($fileInstance)) {
214 + continue;
215 + } // when class not found, skip load script
216 + $script .= $fileInstance::init($scriptFileArr['fk'], $scriptFileArr['field'], $scriptFileArr['contentId']);
217 + }
192 218 }
193 219 return $script;
194 220 }
195 221
@@ -197,12 +223,8 @@
197 223 {
198 224 foreach ($this->_fields as $flds) {
199 225 foreach ($flds as $fld) {
200 226 $fldData = $fld['field'];
201 - // Corrupt/partial form JSON can produce a null field or one without typ.
202 - if (!is_object($fldData)) {
203 - continue;
204 - }
205 227 // for validation js files
206 228 if (self::isValidationNeeded($fldData)) {
207 229 $validation = $this->_validationJsFilesNeeded['validation'];
208 230 $this->addScriptInLoadedScriptsList($validation);
@@ -222,30 +244,18 @@
222 244
223 245 $validationScriptFileMapping = ScriptFilePriorityManager::validationScriptFileMapping($fldData->typ);
224 246 if ($validationScriptFileMapping) {
225 247 foreach ($validationScriptFileMapping as $key => $value) {
226 - $paths = $value['paths'] ?? [];
227 - $hasMatchingPath = false;
228 - foreach ($paths as $path) {
248 + foreach ($value['paths'] as $path) {
229 249 if (Helpers::property_exists_nested($fldData, $path)) {
230 - $hasMatchingPath = true;
231 - break; // one match is enough
250 + $file = $this->_validationJsFilesNeeded[$key];
251 + $this->addScriptInLoadedScriptsList($file);
232 252 }
233 253 }
234 -
235 - if (!$hasMatchingPath) {
236 - continue;
237 - }
238 -
239 - // Add the main script once
240 - if (!empty($this->_validationJsFilesNeeded[$key])) {
241 - $this->addScriptInLoadedScriptsList($this->_validationJsFilesNeeded[$key]);
242 - }
243 -
244 - // Add dependencies once each
245 - foreach (($value['dependencies'] ?? []) as $dep) {
246 - if (!empty($this->_validationJsFilesNeeded[$dep])) {
247 - $this->addScriptInLoadedScriptsList($this->_validationJsFilesNeeded[$dep]);
254 + if (isset($value['dependencies'])) {
255 + foreach ($value['dependencies'] as $dependency) {
256 + $dependencyFile = $this->_validationJsFilesNeeded[$dependency];
257 + $this->addScriptInLoadedScriptsList($dependencyFile);
248 258 }
249 259 }
250 260 }
251 261 }
@@ -254,9 +264,8 @@
254 264 }
255 265
256 266 private function jsFieldsNeededFile()
257 267 {
258 - $filePondPluginList = apply_filters('bitform_filepond_plugins_list', []);
259 268 foreach ($this->_fields as $typ => $flds) {
260 269 if (!array_key_exists($typ, $this->_jsFilesNeeded)) {
261 270 continue;
262 271 }
@@ -266,30 +275,26 @@
266 275 if ('advanced-file-up' === $typ) {
267 276 $configs = $fld['field']->config;
268 277 foreach ($configs as $configKey => $config) {
269 278 if ($configs->$configKey) {
270 - if (array_key_exists($configKey, $filePondPluginList)) {
271 - $this->addScriptInLoadedScriptsList($filePondPluginList[$configKey]);
279 + $filepondPlugin = ScriptFilePriorityManager::filePondPlugins($configKey);
280 + if ($filepondPlugin) {
281 + $this->addScriptInLoadedScriptsList($filepondPlugin);
272 282 }
273 283 }
274 284 }
275 285 }
276 286 foreach ($fldScriptArr as $scriptFile) {
277 - if (isset($scriptFile['paths']) && is_array($scriptFile['paths'])) {
278 - $pathMatched = false;
279 - foreach ($scriptFile['paths'] as $path) {
280 - if (Helpers::property_exists_nested($fld['field'], $path)) {
281 - $pathMatched = true;
282 - break;
283 - }
284 - }
285 - if (!$pathMatched) {
286 - continue;
287 - }
288 - } elseif (isset($scriptFile['path']) && !Helpers::property_exists_nested($fld['field'], $scriptFile['path'])) {
287 + if (!isset($scriptFile['scriptTyp'])) {
288 + $this->addScriptInLoadedScriptsList($scriptFile);
289 289 continue;
290 290 }
291 - $this->addScriptInLoadedScriptsList($scriptFile);
291 + if ('custom' === $scriptFile['scriptTyp'] && Helpers::property_exists_nested($fld['field'], $scriptFile['path'], true)) {
292 + $scriptFile['field'] = $fld['field'];
293 + $scriptFile['fk'] = $fld['fk'];
294 + $scriptFile['contentId'] = $fld['contentId'];
295 + $this->addScriptInLoadedScriptsList($scriptFile);
296 + }
292 297 }
293 298 }
294 299 }
295 300 }
@@ -295,15 +300,13 @@
295 300 }
296 301
297 302 private static function getCustomJsCodes($contentIds = [])
298 303 {
299 - $script = 'let bfContentId = "", bfSlNo = "1", bfVars= "";';
304 + $script = 'let bfContentId = "", bfVars= "";';
300 305 foreach ($contentIds as $contentId) {
301 - $contentIdArr = explode('_', $contentId);
302 - $jsCode = self::getCustomCodes($contentIdArr[1])['JavaScript'];
303 - $bfSlNo = array_key_exists(3, $contentIdArr) ? $contentIdArr[3] : '1';
306 + $jsCode = self::getCustomCodes(explode('_', $contentId)[1])['JavaScript'];
304 307 if (!empty($jsCode)) {
305 - $script .= " if(bfSelect('#{$contentId}')){ bfContentId = '{$contentId}'; bfSlNo = '{$bfSlNo}'; bfVars = window.bf_globals.{$contentId}.smartTags; {$jsCode}}";
308 + $script .= " if(bfSelect('#{$contentId}')){ bfContentId = '{$contentId}'; bfVars = window.bf_globals.{$contentId}.smartTags; {$jsCode}}";
306 309 }
307 310 }
308 311
309 312 return $script;
@@ -333,10 +336,9 @@
333 336 {
334 337 // for js file
335 338 $path = 'form-scripts';
336 339 $fileName = "bitform-custom-$formId.js";
337 - $filteredJs = Helpers::removeJsSingleLineComments($customCodes->JavaScript);
338 - self::customCodeFileSaveOrDelete($filteredJs, $path, $fileName);
340 + self::customCodeFileSaveOrDelete($customCodes->JavaScript, $path, $fileName);
339 341
340 342 // for css file
341 343 $path = 'form-styles';
342 344 $fileName = "bitform-custom-$formId.css";
@@ -351,9 +353,11 @@
351 353 Helpers::saveFile($path, $fileName, $script, 'w');
352 354 } else {
353 355 $uploadPath = "$path/$fileName";
354 356 $uploadFilePath = Helpers::generatePathDirOrFile($uploadPath);
355 - FileHandler::deleteIsFileExists($uploadFilePath);
357 + if (file_exists($uploadFilePath)) {
358 + unlink($uploadFilePath);
359 + }
356 360 }
357 361 return true;
358 362 }
359 363
@@ -369,31 +373,26 @@
369 373 return $customCodes;
370 374 }
371 375
372 376 private $fldContainersByType = [
373 - 'address' => '.__$fk__-parent-fld-wrp',
374 - 'select' => '.__$fk__-dpd-fld-wrp',
375 - 'country' => '.__$fk__-country-fld-wrp',
376 - 'currency' => '.__$fk__-currency-fld-wrp',
377 - 'phone-number' => '.__$fk__-phone-fld-wrp',
378 - 'file-up' => '.__$fk__-file-up-wrpr',
379 - 'advanced-file-up' => '#filepond-__$fk__-container',
380 - 'paypal' => '.__$fk__-paypal-wrp',
381 - 'razorpay' => '.__$fk__-razorpay-wrp',
382 - 'recaptcha' => '.__$fk__-recaptcha-wrp',
383 - 'stripe' => '.__$fk__-stripe-fld',
384 - 'mollie' => '.__$fk__-mollie-wrp',
385 - 'repeater' => '.__$fk__-rpt-fld-wrp',
386 - 'signature' => '.__$fk__-inp-fld-wrp',
387 - 'rating' => '.__$fk__-inp-fld-wrp',
388 - 'email-otp' => '.__$fk__-inp-fld-wrp',
389 - 'hcaptcha' => '.__$fk__-h-captcha-wrp',
390 - 'advanced-datetime' => '.__$fk__-advanced-datetime',
377 + 'select' => '.__$fk__-dpd-fld-wrp',
378 + 'country' => '.__$fk__-country-fld-wrp',
379 + 'currency' => '.__$fk__-currency-fld-wrp',
380 + 'phone-number' => '.__$fk__-phone-fld-wrp',
381 + 'file-up' => '.__$fk__-file-up-wrpr',
382 + 'advanced-file-up' => '#filepond-__$fk__-container',
383 + 'paypal' => '.__$fk__-paypal-wrp',
384 + 'razorpay' => '.__$fk__-razorpay-wrp',
385 + 'recaptcha' => '.__$fk__-recaptcha-wrp',
386 + 'stripe' => '.__$fk__-stripe-fld',
387 + 'repeater' => '.__$fk__-rpt-fld-wrp',
388 + 'signature' => '.__$fk__-inp-fld-wrp',
389 + 'rating' => '.__$fk__-inp-fld-wrp',
391 390 ];
392 391
393 392 private function generateFieldConfigsJs()
394 393 {
395 - $customFlds = ['address', 'select', 'country', 'currency', 'phone-number', 'file-up', 'advanced-file-up', 'paypal', 'razorpay', 'stripe', 'mollie', 'recaptcha', 'repeater', 'signature', 'rating', 'turnstile', 'hcaptcha', 'advanced-datetime', 'email-otp'];
394 + $customFlds = ['select', 'country', 'currency', 'phone-number', 'file-up', 'advanced-file-up', 'paypal', 'razorpay', 'stripe', 'recaptcha', 'repeater', 'signature', 'rating', 'turnstile'];
396 395 $allFieldTypes = array_keys($this->_fields);
397 396 $customFldsInForms = array_intersect($allFieldTypes, $customFlds);
398 397 $formContents = $this->_formContents;
399 398 $recaptchaV3Enabled = false;
@@ -415,10 +414,10 @@
415 414 }
416 415
417 416 $customFldConfigPaths = [];
418 417
419 - $allConfs = ScriptFilePriorityManager::getAllFldConfs();
420 418 foreach ($customFldsInForms as $customFldTyp) {
419 + $allConfs = ScriptFilePriorityManager::getAllFldConfs();
421 420 if (isset($allConfs[$customFldTyp])) {
422 421 $customFldConfigPaths[$customFldTyp] = $allConfs[$customFldTyp];
423 422 } else {
424 423 $customFldConfigPaths[$customFldTyp] = (object) [];
@@ -424,48 +423,92 @@
424 423 $customFldConfigPaths[$customFldTyp] = (object) [];
425 424 }
426 425 }
427 426
428 - $customFldConfigPaths = wp_json_encode($customFldConfigPaths);
429 - $containers = wp_json_encode($containers);
427 + $customFldConfigPaths = json_encode($customFldConfigPaths);
428 + $containers = json_encode($containers);
430 429
431 - $script = ' const customFldConfigPaths = ' . $customFldConfigPaths . ';
432 - const fldContainers = ' . $containers . ';
430 + $scriptLoaderFields = ['paypal', 'razorpay', 'stripe', 'recaptcha', 'turnstile'];
431 + $scriptLoadedNeeded = array_intersect($scriptLoaderFields, $customFldsInForms) || $recaptchaV3Enabled;
432 + if ($scriptLoadedNeeded) {
433 + $scriptLoaderJs = ScriptLoader::init();
434 + } else {
435 + $scriptLoaderJs = '';
436 + }
437 +
438 + if (in_array('paypal', $customFldsInForms)) {
439 + $paypalInitJs = Paypal::init();
440 + } else {
441 + $paypalInitJs = '';
442 + }
443 +
444 + if (in_array('razorpay', $customFldsInForms)) {
445 + $razorpayInitJs = Razorpay::init();
446 + } else {
447 + $razorpayInitJs = '';
448 + }
449 +
450 + if (in_array('stripe', $customFldsInForms)) {
451 + $stripeInitJs = Stripe::init();
452 + } else {
453 + $stripeInitJs = '';
454 + }
455 +
456 + if (in_array('recaptcha', $customFldsInForms)) {
457 + $recaptchaInitJs = Recaptcha::init();
458 + } else {
459 + $recaptchaInitJs = '';
460 + }
461 +
462 + if (in_array('turnstile', $customFldsInForms)) {
463 + $turnstileInitJs = Turnstile::init();
464 + } else {
465 + $turnstileInitJs = '';
466 + }
467 +
468 + if ($recaptchaV3Enabled) {
469 + $recaptchaV3InitJs = RecaptchaV3::init();
470 + } else {
471 + $recaptchaV3InitJs = '';
472 + }
473 +
474 + $script = <<<FIELDCONFIGJS
475 + const customFldConfigPaths = $customFldConfigPaths;
476 + const fldContainers = $containers;
433 477
478 + $scriptLoaderJs;
479 +
434 480 function initAllCustomFlds (formContentId = null) {
435 481 const allContendIds = formContentId ? [formContentId] : Object.keys(bf_globals);
436 482 allContendIds.forEach((contentId) => {
437 483 const contentData = bf_globals[contentId];
438 - if(!contentData?.inits) contentData.inits = {};
439 - const flds = bf_globals[contentId]?.fields || {};
484 + const flds = bf_globals[contentId].fields;
440 485 const fldKeys = Object.keys(flds).reverse();
441 486 fldKeys.forEach((fldKey) => {
442 487 const fldData = flds[fldKey];
443 488 const fldType = fldData.typ;
444 - if(fldType === \'paypal\') {
445 - initPaypalFld(contentId, fldKey, fldData, fldType);
446 - } else if(fldType === \'razorpay\') {
447 - initRazorpayFld(contentId, fldKey, fldType);
448 - } else if(fldType === \'recaptcha\') {
449 - initRecaptchaFld(contentId, fldKey, fldType);
450 - } else if(fldType === \'turnstile\') {
451 - initTurnstileFld(contentId, fldKey);
452 - } else if(fldType === \'hcaptcha\') {
453 - initHCaptchaFld(contentId, fldKey, fldType);
454 - } else if(fldType === \'stripe\' || fldType === \'mollie\') {
455 - initStripeFld(contentId, fldKey, fldType);
489 + if(fldType === 'paypal') {
490 + $paypalInitJs;
491 + } else if(fldType === 'razorpay') {
492 + $razorpayInitJs;
493 + } else if(fldType === 'recaptcha') {
494 + $recaptchaInitJs;
495 + } else if(fldType === 'turnstile') {
496 + $turnstileInitJs;
497 + } else if(fldType === 'stripe') {
498 + $stripeInitJs;
456 499 } else if (customFldConfigPaths[fldType]) {
457 500 contentData.inits[fldKey] = getFldInstance(contentId, fldKey, fldType);
458 501 }
459 502 });
460 - if(contentData.gRecaptchaVersion === \'v3\' && contentData.gRecaptchaSiteKey){
461 - initRecaptchaV3Fld(contentId, contentData);
503 + if(contentData.gRecaptchaVersion === 'v3' && contentData.gRecaptchaSiteKey){
504 + $recaptchaV3InitJs;
462 505 }
463 506 });
464 507 };
465 - function getFldInstance(contentId, fldKey, fldTyp, nestedSelector = \'\') {
466 - const fldClass = this[\'bit_\'+fldTyp.replace(/-/g, \'_\')+\'_field\'];
467 - const selector = \'#form-\'+contentId+\' \'+nestedSelector+fldContainers[fldTyp].replace("__$fk__", fldKey);
508 + function getFldInstance(contentId, fldKey, fldTyp, nestedSelector = '') {
509 + const fldClass = this['bit_'+fldTyp.replace(/-/g, '_')+'_field'];
510 + const selector = '#form-'+contentId+' '+nestedSelector+fldContainers[fldTyp].replace("__\$fk__", fldKey);
468 511 if(!fldClass || !bfSelect(selector)) return;
469 512 return new fldClass(selector, getFldConf(contentId, fldKey, fldTyp));
470 513 };
471 514 function getFldConf(contentId, fieldKey, fldTyp) {
@@ -486,13 +529,13 @@
486 529 } else {
487 530 value = getDataFromNestedPath(fldData, fldPath.path);
488 531 }
489 532 }
490 - if (!value && "val" in fldPath) {
533 + if (!value && fldPath.val) {
491 534 value = fldPath.val;
492 - if(typeof value === \'string\') {
535 + if(typeof value === 'string') {
493 536 Object.entries(varData).forEach(([key, val]) => {
494 - value = value.replace("__$"+key+"__", val);
537 + value = value.replace("__\$"+key+"__", val);
495 538 });
496 539 }
497 540 }
498 541 fldConf = setDataToNestedPath(fldConf, confPath, value);
@@ -518,9 +561,10 @@
518 561 current = current[k];
519 562 });
520 563 current[lastKey] = value;
521 564 return current;
522 - }';
565 + }
566 +FIELDCONFIGJS;
523 567
524 568 return $script;
525 569 }
526 570
@@ -541,10 +585,8 @@
541 585 $fileArr = ScriptFilePriorityManager::validationAndOtherScriptFile()['conditionalLogic'];
542 586 $this->addScriptInLoadedScriptsList($fileArr);
543 587 $fileArr = ScriptFilePriorityManager::validationAndOtherScriptFile()['resetPlaceholders'];
544 588 $this->addScriptInLoadedScriptsList($fileArr);
545 - $fileArr = ScriptFilePriorityManager::validationAndOtherScriptFile()['bfResetDefaultValue'];
546 - $this->addScriptInLoadedScriptsList($fileArr);
547 589 $fileArr = ScriptFilePriorityManager::validationAndOtherScriptFile()['validateFocusLost'];
548 590 $this->addScriptInLoadedScriptsList($fileArr);
549 591 $fileArr = ScriptFilePriorityManager::frontendScriptFile()['observeElm'];
550 592 $this->addScriptInLoadedScriptsList($fileArr);
@@ -562,19 +604,8 @@
562 604 if (Helpers::property_exists_nested($appConfig, 'cache_plugin', true)) {
563 605 $fileArr = ScriptFilePriorityManager::frontendScriptFile()['hidden-token-field'];
564 606 $this->addScriptInLoadedScriptsList($fileArr);
565 607 return;
566 - }
567 - }
568 -
569 - private function jsRecaptchaV3Scripts()
570 - {
571 - foreach ($this->_formContents as $content) {
572 - if (isset($content->additional->enabled->recaptchav3) && $content->additional->enabled->recaptchav3) {
573 - $this->addScriptInLoadedScriptsList(['priority' => 302, 'filename' => 'scriptLoader.min.js']);
574 - $this->addScriptInLoadedScriptsList(['priority' => 303, 'filename' => 'initRecaptchaV3Fld.min.js']);
575 - return;
576 - }
577 608 }
578 609 }
579 610
580 611 public function dd($data, $exit = false)