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/Admin/Form/FrontEndScriptGenerator.php +29 -28 3.2.2 → V3.3.2 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
@@ -212,13 +222,14 @@
212 222 $fileArr = $this->_validationJsFilesNeeded['requiredFldValidation'];
213 223 $this->addScriptInLoadedScriptsList($fileArr);
214 224 }
215 225 // for regex
216 - if (Helpers::property_exists_nested($fldData, 'valid->regexr')) {
217 - $patternFile = $this->_validationJsFilesNeeded['generateBackslashPattern'];
218 - $rgx = $this->_validationJsFilesNeeded['regexPatternValidation'];
219 - $this->addScriptInLoadedScriptsList($patternFile);
220 - $this->addScriptInLoadedScriptsList($rgx);
226 + // The RegEx scripts are registered by Pro; without it there is nothing to load.
227 + if (Helpers::property_exists_nested($fldData, 'valid->regexr')
228 + && !empty($this->_validationJsFilesNeeded['generateBackslashPattern'])
229 + && !empty($this->_validationJsFilesNeeded['regexPatternValidation'])) {
230 + $this->addScriptInLoadedScriptsList($this->_validationJsFilesNeeded['generateBackslashPattern']);
231 + $this->addScriptInLoadedScriptsList($this->_validationJsFilesNeeded['regexPatternValidation']);
221 232 }
222 233
223 234 $validationScriptFileMapping = ScriptFilePriorityManager::validationScriptFileMapping($fldData->typ);
224 235 if ($validationScriptFileMapping) {
@@ -580,16 +591,6 @@
580 591 $this->addScriptInLoadedScriptsList(['priority' => 303, 'filename' => 'initRecaptchaV3Fld.min.js']);
581 592 return;
582 593 }
583 594 }
584 - }
585 -
586 - public function dd($data, $exit = false)
587 - {
588 - echo '+++++++++++++';
589 - echo '<pre>';
590 - var_dump($data);
591 - echo '</pre>';
592 - echo '+++++++++++++';
593 - $exit ? exit : '';
594 595 }
595 596 }