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/ScriptFilePriorityManager.php +350 -184 2.03.3.1 View file →
@@ -1,10 +1,12 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Admin\Form;
4 4
5 -class ScriptFilePriorityManager {
6 - public static function jsFile() {
5 +class ScriptFilePriorityManager
6 +{
7 + public static function jsFile()
8 + {
7 9 /**
8 10 * file load priority
9 11 * first priority status code 100
10 12 * sub status code link 101,102
@@ -40,241 +42,354 @@
40 42 submit js
41 43 custom js
42 44 */
43 45 $initSource = '\\BitCode\\BitForm\\Admin\\Form\\InitJs\\';
44 - $customSource = '\\BitCode\\BitForm\\Admin\\Form\\ExtraFieldJS\\';
45 - return [
46 + $files = [
46 47 'helperScript' => [
47 48 ['priority' => 101, 'filename' => 'bfSelect.min.js'],
48 49 ['priority' => 101, 'filename' => 'bfReset.min.js'],
49 50 ['priority' => 101, 'filename' => 'setBFMsg.min.js'],
50 - ['priority' => 101, 'filename' => 'scrollToFld.min.js'],
51 + ['priority' => 101, 'filename' => 'bfSplit.min.js'],
52 + ['priority' => 101, 'filename' => 'scrollToElm.min.js'],
53 + ['priority' => 101, 'filename' => 'getFldKeyAndRowIndx.min.js'],
54 + ['priority' => 101, 'filename' => 'moveToFirstErrFld.min.js'],
51 55 ['priority' => 101, 'filename' => 'bfValidationErrMsg.min.js'],
52 56 ['priority' => 101, 'filename' => 'setHiddenFld.min.js'],
53 57 ['priority' => 101, 'filename' => 'submit-form.min.js'],
54 58 ['priority' => 101, 'filename' => 'setStyleProperty.min.js']
55 59 ],
60 +
61 + 'text' => [
62 + ['priority' => 301, 'filename' => 'initTextLengthHelper.min.js', 'paths' => ['valid->minlength', 'valid->maxlength', 'valid->maxword', 'valid->minword']],
63 + ],
64 + 'textarea' => [
65 + ['priority' => 301, 'filename' => 'initTextLengthHelper.min.js', 'paths' => ['valid->minlength', 'valid->maxlength', 'valid->maxword', 'valid->minword']],
66 + ],
67 + 'range' => [
68 + ['priority' => 301, 'filename' => 'setSliderFieldValue.min.js', 'path' => 'showValue'],
69 + ],
70 + 'password' => [
71 + ['priority' => 301, 'filename' => 'initPasswordStrengthHelper.min.js', 'path' => 'valid->validations'],
72 + ['priority' => 301, 'filename' => 'bfTogglePasswordVisibility.min.js', 'path' => 'config->showPasswordIcon'],
73 + ],
74 + 'address' => [
75 + ['priority' => 101, 'filename' => 'observeElm.min.js'],
76 + ['priority' => 301, 'filename' => 'bit-address-field.min.js'],
77 + ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
78 + ],
56 79 'country' => [
57 80 ['priority' => 101, 'filename' => 'observeElm.min.js'],
58 - ['priority' => 201, 'filename' => 'bit-virtualized-list.min.js'],
59 81 ['priority' => 301, 'filename' => 'bit-country-field.min.js'],
60 - ['priority' => 501, 'filename' => 'Country', 'scriptTyp' => 'init', 'source' => $initSource],
61 82 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
62 83 ['priority' => 101, 'filename' => 'observeElm.min.js'],
63 84 ],
64 85 'currency' => [
65 86 ['priority' => 101, 'filename' => 'observeElm.min.js'],
66 - ['priority' => 201, 'filename' => 'bit-virtualized-list.min.js'],
67 87 ['priority' => 301, 'filename' => 'bit-currency-field.min.js'],
68 - ['priority' => 501, 'filename' => 'Currency', 'scriptTyp' => 'init', 'source' => $initSource],
69 88 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
70 89 ['priority' => 101, 'filename' => 'observeElm.min.js'],
71 90 ],
72 91 'select' => [
73 92 ['priority' => 101, 'filename' => 'observeElm.min.js'],
74 - ['priority' => 301, 'filename' => 'bit-dropdown-field.min.js'],
75 - ['priority' => 501, 'filename' => 'Select', 'scriptTyp' => 'init', 'source' => $initSource],
93 + ['priority' => 301, 'filename' => 'bit-select-field.min.js'],
76 94 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
77 95 ['priority' => 101, 'filename' => 'observeElm.min.js'],
78 96 ],
79 - 'advanced-file-up' => [
80 - ['priority' => 101, 'filename' => 'observeElm.min.js'],
81 - ['priority' => 202, 'filename' => 'bit-filepond.min.js'],
82 - ['priority' => 301, 'filename' => 'bit-advance-file-upload-field.min.js'],
83 - ['priority' => 501, 'filename' => 'AdvancedFileUpload', 'scriptTyp' => 'init', 'source' => $initSource],
84 - ['priority' => 101, 'filename' => 'advancedFileHandle.min.js'],
85 - ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
86 - ],
87 97 'file-up' => [
88 98 ['priority' => 301, 'filename' => 'bit-file-up-field.min.js'],
89 - ['priority' => 501, 'filename' => 'FileUpload', 'scriptTyp' => 'init', 'source' => $initSource],
90 99 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
91 100 ],
92 101 'phone-number' => [
93 102 ['priority' => 101, 'filename' => 'observeElm.min.js'],
94 - ['priority' => 201, 'filename' => 'bit-virtualized-list.min.js'],
95 103 ['priority' => 301, 'filename' => 'bit-phone-number-field.min.js'],
96 - ['priority' => 501, 'filename' => 'PhoneNumber', 'scriptTyp' => 'init', 'source' => $initSource],
97 104 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
98 - ['priority' => 101, 'filename' => 'observeElm.min.js'],
105 + // ['priority' => 101, 'filename' => 'observeElm.min.js'],
99 106 ],
100 - 'paypal' => [
101 - ['priority' => 101, 'filename' => 'paymentSubmitResponse.min.js'],
102 - ['priority' => 301, 'filename' => 'bit-paypal-field.min.js'],
103 - ['priority' => 601, 'filename' => 'Paypal', 'scriptTyp' => 'init', 'source' => $initSource],
107 + 'section' => [
108 + ['priority' => 101, 'filename' => 'hideChildFldHandle.min.js'],
104 109 ],
105 - 'razorpay' => [
106 - ['priority' => 101, 'filename' => 'paymentSubmitResponse.min.js'],
107 - ['priority' => 301, 'filename' => 'bit-razorpay-field.min.js'],
108 - ['priority' => 601, 'filename' => 'Razorpay', 'scriptTyp' => 'init', 'source' => $initSource],
110 + 'repeater' => [
111 + ['priority' => 101, 'filename' => 'hideChildFldHandle.min.js'],
112 + ['priority' => 102, 'filename' => 'bit-repeater-field.min.js'],
113 + ['priority' => 701, 'filename' => 'checkRepeatedField.min.js'],
114 + ['priority' => 701, 'filename' => 'isRepeaterField.min.js'],
115 + ['priority' => 701, 'filename' => 'getRepeatedIndexes.min.js'],
116 + ['priority' => 701, 'filename' => 'getIndexesBaseOnConditions.min.js'],
117 + ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
109 118 ],
110 - 'radio' => [
111 - ['priority' => 301, 'filename' => 'OtherOptionJS', 'scriptTyp' => 'custom', 'source' => $customSource],
119 + 'recaptcha' => [
120 + ['priority' => 301, 'filename' => 'bit-recaptcha-field.min.js'],
121 + ['priority' => 302, 'filename' => 'scriptLoader.min.js'],
122 + ['priority' => 303, 'filename' => 'initRecaptchaFld.min.js'],
112 123 ],
113 - 'check' => [
114 - ['priority' => 301, 'filename' => 'OtherOptionJS', 'scriptTyp' => 'custom', 'source' => $customSource],
115 - ['priority' => 301, 'filename' => 'CheckDisableOnMax', 'scriptTyp' => 'custom', 'source' => $customSource],
124 + 'hcaptcha' => [
125 + ['priority' => 301, 'filename' => 'bit-hcaptcha-field.min.js'],
126 + ['priority' => 302, 'filename' => 'scriptLoader.min.js'],
127 + ['priority' => 303, 'filename' => 'initHCaptchaFld.min.js'],
116 128 ],
117 - 'recaptcha' => [
118 - ['priority' => 301, 'filename' => 'bit-recaptcha-field.min.js'],
119 - ['priority' => 601, 'filename' => 'Recaptcha', 'scriptTyp' => 'init', 'source' => $initSource],
129 + 'turnstile' => [
130 + ['priority' => 302, 'filename' => 'scriptLoader.min.js'],
131 + ['priority' => 303, 'filename' => 'initTurnstileFld.min.js'],
120 132 ],
121 133 'decision-box' => [
122 134 ['priority' => 101, 'filename' => 'decisionFldHandle.min.js'],
123 - ]
135 + ],
136 + 'gdpr' => [
137 + ['priority' => 101, 'filename' => 'decisionFldHandle.min.js'],
138 + ],
139 + 'rating' => [
140 + ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
141 + ['priority' => 301, 'filename' => 'bit-rating-field.min.js'],
142 + ],
143 + 'date' => [
144 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
145 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
146 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
147 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
148 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
149 + ],
150 + 'datetime-local' => [
151 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
152 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
153 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
154 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
155 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
156 + ],
157 + 'time' => [
158 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
159 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
160 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
161 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
162 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
163 + ],
164 + 'month' => [
165 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
166 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
167 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
168 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
169 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
170 + ],
171 + 'week' => [
172 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
173 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
174 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
175 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
176 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
177 + ],
124 178 ];
125 - }
126 179
127 - public static function filePondPlugins($plugin) {
128 - $plugins = [
129 - 'allowFileSizeValidation' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-file-validate-size.min.js'],
130 - 'allowFileTypeValidation' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-file-validate-type.min.js'],
131 - 'allowImageCrop' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-crop.min.js'],
132 - 'allowImagePreview' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-preview.min.js'],
133 - 'allowImageResize' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-resize.min.js'],
134 - 'allowImageTransform' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-transform.min.js'],
135 - 'allowImageValidateSize' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-validate-size.min.js'],
136 - 'allowPreview' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-media-preview.min.js'],
137 - ];
138 - if (array_key_exists($plugin, $plugins)) {
139 - return $plugins[$plugin];
140 - }
141 -
142 - return false;
180 + /**
181 + * Allow add-on plugins (e.g. Pro) to register additional script files
182 + * without shipping those files/paths in the wp.org (free) package.
183 + */
184 + return apply_filters('bitform_script_file_priority_list', $files);
143 185 }
144 186
145 - public static function fieldMissingConfigsProps($fieldType, $field) {
187 + public static function getAllFldConfs()
188 + {
189 + // $contentId = $fieldData['contentId'];
190 + // $fieldKey = $fieldData['fk'];
191 + // $field = $fieldData['field'];
146 192 // key is config path, value is field path
147 193 // var is for variable value
148 - // path is for field path
194 + // path is for field path [ for multiple paths]
149 195 // val is for static value
150 196 $configs = [
197 +
151 198 'select' => [
152 - 'fieldKey' => ['var' => 'fieldKey'],
153 - 'options' => ['path' => 'optionsList'],
154 - 'placeholder' => ['path' => 'ph'],
155 - 'classNames' => ['path' => 'customClasses'],
156 - 'attributes' => ['path' => 'customAttributes'],
157 - 'defaultValue' => ['path' => 'val', 'val' => isset($field->config->defaultValue) ? $field->config->defaultValue : ''],
158 - 'separator' => ['val' => BITFORMS_BF_SEPARATOR],
159 - 'mn' => ['path' => 'mn', 'val' => 0],
160 - 'mx' => ['path' => 'mx', 'val' => 0],
161 - 'disableOnMax' => ['path' => 'valid->disableOnMax', 'val' => false],
199 + 'config' => (object) [], // sentinel: blocks raw fldData.config passthrough;
200 + 'fieldKey' => ['var' => 'fieldKey'],
201 + 'options' => ['path' => 'optionsList'],
202 + 'placeholder' => ['path' => 'ph'],
203 + 'classNames' => ['path' => 'customClasses'],
204 + 'attributes' => ['path' => 'customAttributes'],
205 + 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val' => ''],
206 + 'separator' => ['val' => BITFORMS_BF_SEPARATOR],
207 + 'multipleSelect' => ['path' => 'config->multipleSelect', 'val' => false],
208 + 'showChip' => ['path' => 'config->showChip', 'val' => false],
209 + 'selectedOptClearable' => ['path' => 'config->selectedOptClearable', 'val' => true],
210 + 'searchClearable' => ['path' => 'config->searchClearable', 'val' => true],
211 + 'showSearch' => ['path' => 'config->showSearch', 'val' => true],
212 + 'searchPlaceholder' => ['path' => 'config->searchPlaceholder', 'val' => ''],
213 + 'activeList' => ['path' => 'config->activeList', 'val' => 0],
162 214 ],
215 + 'address' => [
216 + 'config' => (object) [],
217 + 'fieldKey' => ['var' => 'fieldKey'],
218 + 'contentId' => ['var' => 'contentId'],
219 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/address/'],
220 + 'fieldName' => ['path' => 'fieldName'],
221 + 'classNames' => ['path' => 'customClasses'],
222 + 'attributes' => ['path' => 'customAttributes'],
223 + 'defaultCountry' => ['path' => 'config->defaultCountry', 'val' => ''],
224 + 'zipValidation' => ['path' => 'config->zipValidation', 'val' => 'auto'],
225 + 'zipCustomRegex' => ['path' => 'config->zipCustomRegex', 'val' => ''],
226 +
227 + ],
163 228 'country' => [
164 - 'fieldKey' => ['var' => 'fieldKey'],
165 - 'options' => ['path' => 'options'],
166 - 'placeholder' => ['path' => 'ph'],
167 - 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
168 - 'classNames' => ['path' => 'customClasses'],
169 - 'attributes' => ['path' => 'customAttributes'],
170 - 'defaultValue' => ['path' => 'val', 'val' => isset($field->config->defaultValue) ? $field->config->defaultValue : ''],
229 + 'config' => (object) [], // sentinel: blocks raw fldData.config passthrough;
230 + 'fieldKey' => ['var' => 'fieldKey'],
231 + 'options' => ['path' => 'options'],
232 + 'placeholder' => ['path' => 'ph'],
233 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
234 + 'classNames' => ['path' => 'customClasses'],
235 + 'attributes' => ['path' => 'customAttributes'],
236 + 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val' => ''],
237 + 'selectedCountryClearable' => ['path' => 'config->selectedCountryClearable', 'val' => true],
238 + 'searchClearable' => ['path' => 'config->searchClearable', 'val' => true],
239 + 'searchPlaceholder' => ['path' => 'config->searchPlaceholder', 'val' => ''],
171 240 ],
172 241 'currency' => [
173 - 'fieldKey' => ['var' => 'fieldKey'],
174 - 'options' => ['path' => 'options'],
175 - 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/currencies/'],
176 - 'classNames' => ['path' => 'customClasses'],
177 - 'attributes' => ['path' => 'customAttributes'],
178 - 'defaultValue' => ['path' => 'val', 'val' => isset($field->config->defaultValue) ? $field->config->defaultValue : ''],
242 + 'config' => (object) [], // sentinel: blocks raw fldData.config
243 + 'fieldKey' => ['var' => 'fieldKey'],
244 + 'options' => ['path' => 'options'],
245 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/currencies/'],
246 + 'classNames' => ['path' => 'customClasses'],
247 + 'attributes' => ['path' => 'customAttributes'],
248 + 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val' => ''],
249 + 'selectedCurrencyClearable' => ['path' => 'config->selectedCurrencyClearable', 'val' => true],
250 + 'searchClearable' => ['path' => 'config->searchClearable', 'val' => true],
251 + 'searchPlaceholder' => ['path' => 'config->searchPlaceholder', 'val' => ''],
179 252 ],
180 253 'phone-number' => [
181 - 'fieldKey' => ['var' => 'fieldKey'],
182 - 'options' => ['path' => 'options'],
183 - 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
184 - 'classNames' => ['path' => 'customClasses'],
185 - 'attributes' => ['path' => 'customAttributes']
254 + 'config' => (object) [], // sentinel: blocks raw fldData.config passthrough;
255 + 'fieldKey' => ['var' => 'fieldKey'],
256 + 'options' => ['path' => 'options'],
257 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
258 + 'classNames' => ['path' => 'customClasses'],
259 + 'attributes' => ['path' => 'customAttributes'],
260 + 'contentId' => ['var' => 'contentId'],
261 + 'selectedCountryClearable' => ['path' => 'config->selectedCountryClearable', 'val' => true],
262 + 'searchClearable' => ['path' => 'config->searchClearable', 'val' => true],
263 + 'searchPlaceholder' => ['path' => 'config->searchPlaceholder', 'val' => ''],
186 264 ],
187 265 'file-up' => [
188 - 'fieldKey' => ['var' => 'fieldKey'],
189 - 'maxSizeErrMsg' => ['path' => isset($field->err->maxSize->msg) ? 'err->maxSize->msg' : 'err->maxSize->dflt'],
190 - 'minFileErrMsg' => ['path' => isset($field->err->minFile->msg) ? 'err->minFile->msg' : 'err->minFile->dflt'],
191 - 'maxFileErrMsg' => ['path' => isset($field->err->maxFile->msg) ? 'err->maxFile->msg' : 'err->maxFile->dflt'],
192 - 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/file-upload/'],
193 - 'classNames' => ['path' => 'customClasses'],
194 - 'attributes' => ['path' => 'customAttributes']
266 + 'config' => (object) [], // sentinel: blocks raw fldData.config passthrough;
267 + 'fieldKey' => ['var' => 'fieldKey'],
268 + 'formID' => ['var' => 'formId'],
269 + 'maxSizeErrMsg' => ['path' => ['err->maxSize->msg', 'err->maxSize->dflt']],
270 + 'minFileErrMsg' => ['path' => ['err->minFile->msg', 'err->minFile->dflt']],
271 + 'maxFileErrMsg' => ['path' => ['err->maxFile->msg', 'err->maxFile->dflt']],
272 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/file-upload'],
273 + 'classNames' => ['path' => 'customClasses'],
274 + 'attributes' => ['path' => 'customAttributes'],
275 + 'fieldName' => ['path' => 'fieldName'],
276 + 'contentId' => ['var' => 'contentId'],
277 + 'multiple' => ['path' => 'config->multiple', 'val' => false],
278 + 'allowMaxSize' => ['path' => 'config->allowMaxSize', 'val' => false],
279 + 'maxSize' => ['path' => 'config->maxSize', 'val' => 0],
280 + 'sizeUnit' => ['path' => 'config->sizeUnit', 'val' => 'KB'],
281 + 'isItTotalMax' => ['path' => 'config->isItTotalMax', 'val' => false],
282 + 'allowedFileType' => ['path' => 'config->allowedFileType', 'val' => ''],
283 + 'minFile' => ['path' => 'config->minFile', 'val' => 0],
284 + 'maxFile' => ['path' => 'config->maxFile', 'val' => 0],
285 + 'showSelectStatus' => ['path' => 'config->showSelectStatus', 'val' => false],
286 + 'fileSelectStatus' => ['path' => 'config->fileSelectStatus', 'val' => 'No File Selected'],
287 + 'oldFiles' => ['path' => 'config->oldFiles', 'val' => []],
288 + 'baseDLURL' => ['path' => 'config->baseDLURL', 'val' => ''],
289 + 'fileExistMsg' => ['val' => 'A file already exist'],
290 + 'showFileList' => ['path' => 'config->showFileList', 'val' => false],
291 + 'showFilePreview' => ['path' => 'config->showFilePreview', 'val' => false],
292 + 'showFileSize' => ['path' => 'config->showFileSize', 'val' => false],
293 + 'fileExistMsg' => ['path' => 'config->fileExistMsg', 'val' => 'A file already exist'],
195 294 ],
196 - 'paypal' => [
197 - 'payIntegID' => ['path' => 'payIntegID'],
198 - 'style' => ['path' => 'style'],
199 - 'currency' => ['path' => 'currency', 'val' => 'USD'],
200 - 'amount' => ['path' => 'amount', 'val' => 0],
201 - 'amountFld' => ['path' => 'amountFld', 'val' => ''],
202 - 'shipping' => ['path' => 'shipping', 'val' => 0],
203 - 'shippingVal' => ['path' => 'shippingFld', 'val' => ''],
204 - 'tax' => ['path' => 'tax', 'val' => 0],
205 - 'taxVal' => ['path' => 'taxFld', 'val' => ''],
206 - 'description' => ['path' => 'description', 'val' => ''],
207 - 'descFld' => ['path' => 'descFld', 'val' => ''],
208 - 'payType' => ['path' => 'payType', 'val' => 'payment'],
209 - 'planId' => ['path' => 'planId', 'val' => ''],
210 - 'locale' => ['path' => 'locale', 'val' => 'en_US'],
211 - 'disableFunding' => ['path' => 'disableFunding', 'val' => ''],
295 + 'repeater' => [
296 + 'config' => (object) [],
297 + 'fieldKey' => ['var' => 'fieldKey'],
298 + 'fieldName' => ['path' => 'fieldName'],
299 + 'contentId' => ['var' => 'contentId'],
300 + 'showAddBtn' => ['path' => 'addBtn->show', 'val' => false],
301 + 'showAddToEndBtn' => ['path' => 'addToEndBtn->show', 'val' => false],
302 + 'defaultValue' => ['path' => 'val', 'val' => ''],
212 303 ],
213 - 'advanced-file-up' => [
214 - 'fieldKey' => ['var' => 'fieldKey'],
215 - 'formID' => ['var' => 'formID'],
216 - 'configSetting' => ['path' => 'config'],
217 - 'ajaxURL' => ['val' => admin_url('admin-ajax.php')],
218 - 'nonce' => ['val' => wp_create_nonce('bitforms_save')],
219 - 'uploadFileToServer' => ['val' => 1],
304 + 'rating' => [
305 + 'fieldKey' => ['var' => 'fieldKey'],
306 + 'contentId' => ['var' => 'contentId'],
307 + 'options' => ['path' => 'opt'],
308 + 'selectedRating' => ['path' => 'selectedRating'],
309 + 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
220 310 ],
221 - 'razorpay' => [
222 - 'fieldKey' => ['var' => 'fieldKey'],
223 - 'options' => ['path' => 'options'],
224 - 'payIntegID' => ['path' => 'payIntegID'],
225 - 'payType' => ['path' =>'payType', 'val' => ''],
311 + 'hcaptcha'=> [
312 + 'fieldKey' => ['var'=>'fieldKey']
226 313 ],
227 314 ];
315 + /**
316 + * Allow add-on plugins to extend field config mappings.
317 + */
318 + return apply_filters('bitform_field_config_paths', $configs);
319 + }
228 320
229 - return isset($configs[$fieldType]) ? $configs[$fieldType] : [];
321 + public static function multiStepFiles()
322 + {
323 + return [
324 + ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
325 + ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
326 + ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
327 + ['priority' => 700, 'filename' => 'bit-multi-step-form.min.js'],
328 + ];
230 329 }
231 330
232 - public static function frontendScriptFile() {
331 + public static function conversationalFormFiles()
332 + {
233 333 return [
234 - 'observeElm' => ['priority' => 101, 'filename' => 'observeElm.min.js'],
235 - 'hidden-token-field' => ['priority' => 300, 'filename' => 'hidden-token-field.min.js'],
334 + ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
335 + ['priority' => 700, 'filename' => 'bit-conversational-form.min.js'],
336 + ['priority' => 700, 'filename' => 'handleConversationalFormMsg.min.js'],
236 337 ];
237 338 }
238 339
239 - public static function validationScriptFile() {
340 + public static function frontendScriptFile()
341 + {
240 342 return [
241 - 'checkFldValidation' => ['priority' => 701, 'filename' => 'checkFldValidation.min.js'],
242 - 'checkMinMaxOptions' => ['priority' => 702, 'filename' => 'checkMinMaxOptions.min.js'],
243 - 'customOptionValidation' => ['priority' => 702, 'filename' => 'customOptionValidation.min.js'],
244 - 'dcsnbxFldValidation' => ['priority' => 702, 'filename' => 'dcsnbxFldValidation.min.js'],
245 - 'emailFldValidation' => ['priority' => 702, 'filename' => 'emailFldValidation.min.js'],
246 - 'fileupFldValidation' => ['priority' => 702, 'filename' => 'fileupFldValidation.min.js'],
247 - 'advanceFileupFldValidation' => ['priority' => 702, 'filename' => 'advanceFileUpFldValidation.min.js'],
248 - 'phoneNumberFldValidation' => ['priority' => 702, 'filename' => 'phoneNumberFldValidation.min.js'],
249 - 'generateBackslashPattern' => ['priority' => 700, 'filename' => 'generateBackslashPattern.min.js'],
250 - 'nmbrFldValidation' => ['priority' => 702, 'filename' => 'nmbrFldValidation.min.js'],
251 - 'regexPatternValidation' => ['priority' => 701, 'filename' => 'regexPatternValidation.min.js'], // load before generateBackslashPattern file, then load regexPatternValidation
252 - 'requiredFldValidation' => ['priority' => 700, 'filename' => 'requiredFldValidation.min.js'],
253 - 'urlFldValidation' => ['priority' => 702, 'filename' => 'urlFldValidation.min.js'],
254 - 'validation' => ['priority' => 705, 'filename' => 'validateForm.min.js'], // last priority for validation script
255 - 'conditionalLogic' => ['priority' => 705, 'filename' => 'bit-conditionals.min.js'], // last priority for validation script
256 - 'validateFocusLost' => ['priority' => 706, 'filename' => 'validate-focus.min.js'], // last priority for validation script
343 + 'observeElm' => ['priority' => 101, 'filename' => 'observeElm.min.js'],
344 + 'hidden-token-field' => ['priority' => 300, 'filename' => 'hidden-token-field.min.js'],
257 345 ];
258 346 }
259 347
260 - public static function validationCommonFunction() {
261 - $commonFunctions = [
262 - 'requiredFldValidation' => [
263 - 'fields' => ['text', 'email'] // string { all} or array {field name} of field types
264 - ],
265 - 'commonFuncion2' => [
266 - 'notFields' => ['text', 'email'],
267 - 'dependencies' => ['someDependsOnThisField'],
268 - 'paths' => ['path1', 'path2'],
269 - ],
348 + public static function validationAndOtherScriptFile()
349 + {
350 + $files = [
351 + 'confirmFldMatch' => ['priority' => 701, 'filename' => 'confirmFldMatch.min.js'],
352 + 'checkFldValidation' => ['priority' => 701, 'filename' => 'checkFldValidation.min.js'],
353 + // 'checkMinMaxOptions' => ['priority' => 702, 'filename' => 'checkMinMaxOptions.min.js'],
354 + // 'bfDatetimeFldValidation' => ['priority' => 702, 'filename' => 'bfDatetimeFldValidation.min.js'],
355 + 'bfParseDateTime' => ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
356 + 'checkMinMaxValue' => ['priority' => 702, 'filename' => 'checkMinMaxValue.min.js'],
357 + 'textLengthValidation' => ['priority' => 702, 'filename' => 'textLengthValidation.min.js'],
358 + 'customOptionValidation' => ['priority' => 702, 'filename' => 'customOptionValidation.min.js'],
359 + 'dcsnbxFldValidation' => ['priority' => 702, 'filename' => 'dcsnbxFldValidation.min.js'],
360 + 'emailFldValidation' => ['priority' => 702, 'filename' => 'emailFldValidation.min.js'],
361 + 'fileupFldValidation' => ['priority' => 702, 'filename' => 'fileupFldValidation.min.js'],
362 + 'advanceFileupFldValidation' => ['priority' => 702, 'filename' => 'advanceFileUpFldValidation.min.js'],
363 + 'phoneNumberFldValidation' => ['priority' => 702, 'filename' => 'phoneNumberFldValidation.min.js'],
364 + 'currencyFldValidation' => ['priority' => 702, 'filename' => 'currencyFldValidation.min.js'],
365 + 'addressZipFldValidation' => ['priority' => 702, 'filename' => 'addressZipFldValidation.min.js'],
366 + 'generateBackslashPattern' => ['priority' => 700, 'filename' => 'generateBackslashPattern.min.js'],
367 + // 'nmbrFldValidation' => ['priority' => 702, 'filename' => 'nmbrFldValidation.min.js'],
368 + // 'regexPatternValidation' => ['priority' => 701, 'filename' => 'regexPatternValidation.min.js'], // load before generateBackslashPattern file, then load regexPatternValidation
369 + 'inputMaskValidation' => ['priority' => 701, 'filename' => 'inputMaskValidation.min.js'], // load before generateBackslashPattern file, then load inputMaskValidation
370 + 'bit-input-mask' => ['priority' => 701, 'filename' => 'bit-input-mask.min.js'], // load before generateBackslashPattern file, then load bit-input-mask
371 + 'setBitInputMaskToInput' => ['priority' => 702, 'filename' => 'setBitInputMaskToInput.min.js'], // load before generateBackslashPattern file, then load setBitInputMaskToInput
372 + 'requiredFldValidation' => ['priority' => 700, 'filename' => 'requiredFldValidation.min.js'],
373 + 'urlFldValidation' => ['priority' => 702, 'filename' => 'urlFldValidation.min.js'],
374 + 'validation' => ['priority' => 705, 'filename' => 'validateForm.min.js'], // last priority for validation script
375 + 'conditionalLogic' => ['priority' => 705, 'filename' => 'bit-conditionals.min.js'], // last priority for validation script
376 + 'resetPlaceholders' => ['priority' => 201, 'filename' => 'resetPlaceholders.min.js'],
377 + 'bfResetDefaultValue' => ['priority' => 201, 'filename' => 'bfResetDefaultValue.min.js'],
378 + 'validateFocusLost' => ['priority' => 706, 'filename' => 'validate-focus.min.js'], // last priority for validation script
270 379 ];
271 380
272 - return $commonFunctions;
381 + /**
382 + * Allow add-on plugins to register additional validation scripts.
383 + */
384 + return apply_filters('bitform_validation_and_other_script_files', $files);
273 385 }
274 386
275 - public static function validationScriptFileMapping($fieldType) {
276 - $textTypeField = ['text', 'password', 'username', 'url', 'date', 'datetime-local', 'time', 'month', 'week', 'color'];
387 + public static function validationScriptFileMapping($fieldType)
388 + {
389 + // Pro filter callbacks type-hint string; never let null/non-string through.
390 + $fieldType = is_string($fieldType) ? $fieldType : '';
391 + $textTypeField = ['text', 'password', 'username', 'color'];
277 392 if (in_array($fieldType, $textTypeField)) {
278 393 $fieldType = 'text';
279 394 }
280 395 $fields =
@@ -279,15 +394,53 @@
279 394 }
280 395 $fields =
281 396 [
282 397 'text' => [
283 - 'regexPatternValidation' => [
284 - 'paths' => ['valid->regexr'],
398 + 'bit-input-mask' => [
399 + 'paths' => ['valid->inputMask'],
400 + ],
401 + 'inputMaskValidation' => [
402 + 'paths' => ['valid->inputMask'],
285 403 'dependencies' => [
286 - 'generateBackslashPattern'
404 + 'generateBackslashPattern',
405 + 'validation',
287 406 ]
407 + ],
408 + 'setBitInputMaskToInput' => [
409 + 'paths' => ['valid->inputMask'],
410 + 'dependencies' => [
411 + 'bit-input-mask'
412 + ]
413 + ],
414 + 'textLengthValidation' => [
415 + 'paths' => ['valid->minlength', 'valid->maxlength', 'valid->minword', 'valid->maxword']
416 + ],
417 + 'confirmFldMatch' => [
418 + 'paths' => ['parentFieldKey'],
288 419 ]
420 +
289 421 ],
422 + 'textarea' => [
423 + 'bit-input-mask' => [
424 + 'paths' => ['valid->inputMask'],
425 + ],
426 + 'inputMaskValidation' => [
427 + 'paths' => ['valid->inputMask'],
428 + 'dependencies' => [
429 + 'generateBackslashPattern',
430 + 'validation',
431 + ]
432 + ],
433 + 'setBitInputMaskToInput' => [
434 + 'paths' => ['valid->inputMask'],
435 + 'dependencies' => [
436 + 'bit-input-mask'
437 + ]
438 + ],
439 + 'textLengthValidation' => [
440 + 'paths' => ['valid->minlength', 'valid->maxlength', 'valid->minword', 'valid->maxword']
441 + ]
442 + ],
290 443 'email' => [
291 444 'emailFldValidation' => [
292 445 'paths' => ['err->invalid->show'],
293 446 'dependencies' => [
@@ -293,8 +446,11 @@
293 446 'dependencies' => [
294 447 'generateBackslashPattern'
295 448 ]
296 449 ],
450 + 'confirmFldMatch' => [
451 + 'paths' => ['parentFieldKey'],
452 + ]
297 453 ],
298 454 'number' => [
299 455 'nmbrFldValidation' => [
300 456 'paths' => ['mn', 'mx']
@@ -299,37 +455,34 @@
299 455 'nmbrFldValidation' => [
300 456 'paths' => ['mn', 'mx']
301 457 ]
302 458 ],
303 - 'radio' => [
304 - 'customOptionValidation' => [
305 - 'paths' => ['valid->otherOptReq'],
459 + 'range' => [
460 + 'checkMinMaxValue' => [
461 + 'paths' => ['mn', 'mx']
306 462 ]
307 463 ],
308 - 'check' => [
309 - 'checkMinMaxOptions' => [
310 - 'paths' => ['mn', 'mx'],
464 + 'url' => [
465 + 'urlFldValidation' => [
466 + 'paths' => ['err->invalid->show'],
311 467 'dependencies' => [
312 - 'checkFldValidation'
468 + 'generateBackslashPattern'
313 469 ]
314 470 ],
315 - 'customOptionValidation' => [
316 - 'paths' => ['valid->otherOptReq'],
317 - ]
318 - ],
319 - 'select' => [
320 - 'checkMinMaxOptions' => [
321 - 'paths' => ['mn', 'mx'],
471 + 'bit-input-mask' => [
472 + 'paths' => ['valid->inputMask'],
473 + ],
474 + 'inputMaskValidation' => [
475 + 'paths' => ['valid->inputMask'],
322 476 'dependencies' => [
323 - 'checkFldValidation'
477 + 'generateBackslashPattern',
478 + 'validation',
324 479 ]
325 480 ],
326 - ],
327 - 'url' => [
328 - 'urlFldValidation' => [
329 - 'paths' => ['err->invalid->show'],
481 + 'setBitInputMaskToInput' => [
482 + 'paths' => ['valid->inputMask'],
330 483 'dependencies' => [
331 - 'generateBackslashPattern'
484 + 'bit-input-mask'
332 485 ]
333 486 ]
334 487 ],
335 488 'decision-box' => [
@@ -336,15 +489,15 @@
336 489 'dcsnbxFldValidation' => [
337 490 'paths' => ['valid->req']
338 491 ]
339 492 ],
340 - 'file-up' => [
341 - 'fileupFldValidation' => [
493 + 'gdpr' => [
494 + 'dcsnbxFldValidation' => [
342 495 'paths' => ['valid->req']
343 496 ]
344 497 ],
345 - 'advanced-file-up' => [
346 - 'advanceFileupFldValidation' => [
498 + 'file-up' => [
499 + 'fileupFldValidation' => [
347 500 'paths' => ['valid->req']
348 501 ]
349 502 ],
350 503 'phone-number' => [
@@ -351,8 +504,21 @@
351 504 'phoneNumberFldValidation' => [
352 505 'paths' => ['err->invalid->show'],
353 506 ]
354 507 ],
508 + 'address' => [
509 + 'addressZipFldValidation' => [
510 + 'paths' => ['config->zipValidation'],
511 + 'dependencies' => [
512 + 'validation',
513 + ]
514 + ]
515 + ],
355 516 ];
356 - return isset($fields[$fieldType]) ? $fields[$fieldType] : [];
517 + $mapping = isset($fields[$fieldType]) ? $fields[$fieldType] : [];
518 +
519 + /**
520 + * Allow pro add-ons to extend/override mapping per field type.
521 + */
522 + return apply_filters('bitform_field_validation_script_file_mapping', $mapping, $fieldType);
357 523 }
358 524 }