PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
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/Admin/Form/FrontEndScriptGenerator.php +36 -25 V3.0.23.3.1 View file →
@@ -31,22 +31,30 @@
31 31 private static function generateBfGlobalObjJS($contentIds = [])
32 32 {
33 33 $contentidArray = wp_json_encode($contentIds);
34 34 return ' if(!window.bf_globals){ window.bf_globals = {};}
35 - ' . $contentidArray . '.forEach(function(contentId){
36 - const form = document.getElementById(contentId);
37 - if(!form){
38 - delete window.bf_globals[contentId];
39 - return;
40 - }
41 - if(!window.bf_globals[contentId]){
42 - window.bf_globals[contentId] = {inits: {}, contentId: contentId};
43 - }else{
44 - window.bf_globals[contentId].inits = {};
45 - window.bf_globals[contentId].contentId = contentId;
35 + (function(){
36 + var bfSetupGlobals = function(){
37 + ' . $contentidArray . '.forEach(function(contentId){
38 + const form = document.getElementById(contentId);
39 + if(!form){
40 + delete window.bf_globals[contentId];
41 + return;
42 + }
43 + if(!window.bf_globals[contentId]){
44 + window.bf_globals[contentId] = {inits: {}, contentId: contentId};
45 + }else{
46 + if(!window.bf_globals[contentId].inits) window.bf_globals[contentId].inits = {};
47 + window.bf_globals[contentId].contentId = contentId;
48 + }
49 + });
50 + };
51 + if(document.readyState === "loading"){
52 + document.addEventListener("DOMContentLoaded", bfSetupGlobals, { once: true });
53 + } else {
54 + bfSetupGlobals();
46 55 }
47 -
48 - });';
56 + })();';
49 57 }
50 58
51 59 private static function isValidationNeeded($fldData)
52 60 {
@@ -102,8 +110,10 @@
102 110 $this->appendJs($this->getScript(), $postId, $preview);
103 111 $this->appendJs($this->generateFieldConfigsJs($contentIds), $postId, $preview);
104 112 // init all js events and functions at last
105 113 $this->appendJs(self::getFileFromAssetsJs('bitform-init.min.js'), $postId, $preview);
114 + // picks up forms injected after load (AJAX, popups, lazy content)
115 + $this->appendJs(self::getFileFromAssetsJs('bitform-observer.min.js'), $postId, $preview);
106 116 if (defined('ELEMENTOR_PRO_VERSION')) {
107 117 $this->appendJs(self::getFileFromAssetsJs('bitform-elementor.min.js'), $postId, $preview);
108 118 }
109 119
@@ -197,8 +207,12 @@
197 207 {
198 208 foreach ($this->_fields as $flds) {
199 209 foreach ($flds as $fld) {
200 210 $fldData = $fld['field'];
211 + // Corrupt/partial form JSON can produce a null field or one without typ.
212 + if (!is_object($fldData)) {
213 + continue;
214 + }
201 215 // for validation js files
202 216 if (self::isValidationNeeded($fldData)) {
203 217 $validation = $this->_validationJsFilesNeeded['validation'];
204 218 $this->addScriptInLoadedScriptsList($validation);
@@ -365,8 +379,9 @@
365 379 return $customCodes;
366 380 }
367 381
368 382 private $fldContainersByType = [
383 + 'address' => '.__$fk__-parent-fld-wrp',
369 384 'select' => '.__$fk__-dpd-fld-wrp',
370 385 'country' => '.__$fk__-country-fld-wrp',
371 386 'currency' => '.__$fk__-currency-fld-wrp',
372 387 'phone-number' => '.__$fk__-phone-fld-wrp',
@@ -386,9 +401,9 @@
386 401 ];
387 402
388 403 private function generateFieldConfigsJs()
389 404 {
390 - $customFlds = ['select', 'country', 'currency', 'phone-number', 'file-up', 'advanced-file-up', 'paypal', 'razorpay', 'stripe', 'mollie', 'recaptcha', 'repeater', 'signature', 'rating', 'turnstile', 'hcaptcha', 'advanced-datetime', 'email-otp'];
405 + $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'];
391 406 $allFieldTypes = array_keys($this->_fields);
392 407 $customFldsInForms = array_intersect($allFieldTypes, $customFlds);
393 408 $formContents = $this->_formContents;
394 409 $recaptchaV3Enabled = false;
@@ -553,9 +568,15 @@
553 568
554 569 private function jsHiddenFieldScript()
555 570 {
556 571 $appConfig = get_option('bitform_app_config');
557 - if (Helpers::property_exists_nested($appConfig, 'cache_plugin', true)) {
572 + $cacheTokenEnabled = true;
573 + if (is_object($appConfig) && property_exists($appConfig, 'cache_plugin')) {
574 + $cacheTokenEnabled = (bool) $appConfig->cache_plugin;
575 + } elseif (is_array($appConfig) && array_key_exists('cache_plugin', $appConfig)) {
576 + $cacheTokenEnabled = (bool) $appConfig['cache_plugin'];
577 + }
578 + if ($cacheTokenEnabled) {
558 579 $fileArr = ScriptFilePriorityManager::frontendScriptFile()['hidden-token-field'];
559 580 $this->addScriptInLoadedScriptsList($fileArr);
560 581 return;
561 582 }
@@ -569,16 +590,6 @@
569 590 $this->addScriptInLoadedScriptsList(['priority' => 303, 'filename' => 'initRecaptchaV3Fld.min.js']);
570 591 return;
571 592 }
572 593 }
573 - }
574 -
575 - public function dd($data, $exit = false)
576 - {
577 - echo '+++++++++++++';
578 - echo '<pre>';
579 - var_dump($data);
580 - echo '</pre>';
581 - echo '+++++++++++++';
582 - $exit ? exit : '';
583 594 }
584 595 }