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/ScriptFilePriorityManager.php +359 -183 2.0 → V3.3.2 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,361 @@
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 + // Fills field-value Smart Tags (e.g. ${b1-3}) in HTML elements as the visitor types
111 + 'html' => [
112 + ['priority' => 301, 'filename' => 'bfHtmlFieldValueTags.min.js'],
109 113 ],
110 - 'radio' => [
111 - ['priority' => 301, 'filename' => 'OtherOptionJS', 'scriptTyp' => 'custom', 'source' => $customSource],
114 + 'repeater' => [
115 + ['priority' => 101, 'filename' => 'hideChildFldHandle.min.js'],
116 + ['priority' => 102, 'filename' => 'bit-repeater-field.min.js'],
117 + ['priority' => 701, 'filename' => 'checkRepeatedField.min.js'],
118 + ['priority' => 701, 'filename' => 'isRepeaterField.min.js'],
119 + ['priority' => 701, 'filename' => 'getRepeatedIndexes.min.js'],
120 + ['priority' => 701, 'filename' => 'getIndexesBaseOnConditions.min.js'],
121 + ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
112 122 ],
113 - 'check' => [
114 - ['priority' => 301, 'filename' => 'OtherOptionJS', 'scriptTyp' => 'custom', 'source' => $customSource],
115 - ['priority' => 301, 'filename' => 'CheckDisableOnMax', 'scriptTyp' => 'custom', 'source' => $customSource],
116 - ],
117 123 'recaptcha' => [
118 124 ['priority' => 301, 'filename' => 'bit-recaptcha-field.min.js'],
119 - ['priority' => 601, 'filename' => 'Recaptcha', 'scriptTyp' => 'init', 'source' => $initSource],
125 + ['priority' => 302, 'filename' => 'scriptLoader.min.js'],
126 + ['priority' => 303, 'filename' => 'initRecaptchaFld.min.js'],
120 127 ],
128 + 'hcaptcha' => [
129 + ['priority' => 301, 'filename' => 'bit-hcaptcha-field.min.js'],
130 + ['priority' => 302, 'filename' => 'scriptLoader.min.js'],
131 + ['priority' => 303, 'filename' => 'initHCaptchaFld.min.js'],
132 + ],
133 + 'turnstile' => [
134 + ['priority' => 302, 'filename' => 'scriptLoader.min.js'],
135 + ['priority' => 303, 'filename' => 'initTurnstileFld.min.js'],
136 + ],
121 137 'decision-box' => [
122 138 ['priority' => 101, 'filename' => 'decisionFldHandle.min.js'],
123 - ]
139 + ],
140 + 'gdpr' => [
141 + ['priority' => 101, 'filename' => 'decisionFldHandle.min.js'],
142 + ],
143 + 'rating' => [
144 + ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
145 + ['priority' => 301, 'filename' => 'bit-rating-field.min.js'],
146 + ],
147 + 'date' => [
148 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
149 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
150 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
151 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
152 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
153 + ],
154 + 'datetime-local' => [
155 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
156 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
157 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
158 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
159 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
160 + ],
161 + 'time' => [
162 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
163 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
164 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
165 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
166 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
167 + ],
168 + 'month' => [
169 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
170 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
171 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
172 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
173 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
174 + ],
175 + 'week' => [
176 + ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
177 + ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
178 + ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
179 + ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
180 + ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
181 + ],
124 182 ];
125 - }
126 183
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;
184 + /**
185 + * Allow add-on plugins (e.g. Pro) to register additional script files
186 + * without shipping those files/paths in the wp.org (free) package.
187 + */
188 + return apply_filters('bitform_script_file_priority_list', $files);
143 189 }
144 190
145 - public static function fieldMissingConfigsProps($fieldType, $field) {
191 + public static function getAllFldConfs()
192 + {
193 + // $contentId = $fieldData['contentId'];
194 + // $fieldKey = $fieldData['fk'];
195 + // $field = $fieldData['field'];
146 196 // key is config path, value is field path
147 197 // var is for variable value
148 - // path is for field path
198 + // path is for field path [ for multiple paths]
149 199 // val is for static value
150 200 $configs = [
201 +
151 202 '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],
203 + 'config' => (object) [], // sentinel: blocks raw fldData.config passthrough;
204 + 'fieldKey' => ['var' => 'fieldKey'],
205 + 'options' => ['path' => 'optionsList'],
206 + 'placeholder' => ['path' => 'ph'],
207 + 'classNames' => ['path' => 'customClasses'],
208 + 'attributes' => ['path' => 'customAttributes'],
209 + 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val' => ''],
210 + 'separator' => ['val' => BITFORMS_BF_SEPARATOR],
211 + 'multipleSelect' => ['path' => 'config->multipleSelect', 'val' => false],
212 + 'showChip' => ['path' => 'config->showChip', 'val' => false],
213 + 'selectedOptClearable' => ['path' => 'config->selectedOptClearable', 'val' => true],
214 + 'searchClearable' => ['path' => 'config->searchClearable', 'val' => true],
215 + 'showSearch' => ['path' => 'config->showSearch', 'val' => true],
216 + 'searchPlaceholder' => ['path' => 'config->searchPlaceholder', 'val' => ''],
217 + 'activeList' => ['path' => 'config->activeList', 'val' => 0],
162 218 ],
219 + 'address' => [
220 + 'config' => (object) [],
221 + 'fieldKey' => ['var' => 'fieldKey'],
222 + 'contentId' => ['var' => 'contentId'],
223 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/address/'],
224 + 'fieldName' => ['path' => 'fieldName'],
225 + 'classNames' => ['path' => 'customClasses'],
226 + 'attributes' => ['path' => 'customAttributes'],
227 + 'defaultCountry' => ['path' => 'config->defaultCountry', 'val' => ''],
228 + 'zipValidation' => ['path' => 'config->zipValidation', 'val' => 'auto'],
229 + 'zipCustomRegex' => ['path' => 'config->zipCustomRegex', 'val' => ''],
230 +
231 + ],
163 232 '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 : ''],
233 + 'config' => (object) [], // sentinel: blocks raw fldData.config passthrough;
234 + 'fieldKey' => ['var' => 'fieldKey'],
235 + 'options' => ['path' => 'options'],
236 + 'placeholder' => ['path' => 'ph'],
237 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
238 + 'classNames' => ['path' => 'customClasses'],
239 + 'attributes' => ['path' => 'customAttributes'],
240 + 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val' => ''],
241 + 'selectedCountryClearable' => ['path' => 'config->selectedCountryClearable', 'val' => true],
242 + 'searchClearable' => ['path' => 'config->searchClearable', 'val' => true],
243 + 'searchPlaceholder' => ['path' => 'config->searchPlaceholder', 'val' => ''],
171 244 ],
172 245 '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 : ''],
246 + 'config' => (object) [], // sentinel: blocks raw fldData.config
247 + 'fieldKey' => ['var' => 'fieldKey'],
248 + 'options' => ['path' => 'options'],
249 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/currencies/'],
250 + 'classNames' => ['path' => 'customClasses'],
251 + 'attributes' => ['path' => 'customAttributes'],
252 + 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val' => ''],
253 + 'selectedCurrencyClearable' => ['path' => 'config->selectedCurrencyClearable', 'val' => true],
254 + 'searchClearable' => ['path' => 'config->searchClearable', 'val' => true],
255 + 'searchPlaceholder' => ['path' => 'config->searchPlaceholder', 'val' => ''],
179 256 ],
180 257 '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']
258 + 'config' => (object) [], // sentinel: blocks raw fldData.config passthrough;
259 + 'fieldKey' => ['var' => 'fieldKey'],
260 + 'options' => ['path' => 'options'],
261 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
262 + 'classNames' => ['path' => 'customClasses'],
263 + 'attributes' => ['path' => 'customAttributes'],
264 + 'contentId' => ['var' => 'contentId'],
265 + 'selectedCountryClearable' => ['path' => 'config->selectedCountryClearable', 'val' => true],
266 + 'searchClearable' => ['path' => 'config->searchClearable', 'val' => true],
267 + 'searchPlaceholder' => ['path' => 'config->searchPlaceholder', 'val' => ''],
268 + // v3 Edit Options saved the default country as config->defaultValue before it wrote defaultCountryKey.
269 + 'defaultCountryKey' => ['path' => ['config->defaultCountryKey', 'config->defaultValue'], 'val' => ''],
186 270 ],
187 271 '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']
272 + 'config' => (object) [], // sentinel: blocks raw fldData.config passthrough;
273 + 'fieldKey' => ['var' => 'fieldKey'],
274 + 'formID' => ['var' => 'formId'],
275 + 'maxSizeErrMsg' => ['path' => ['err->maxSize->msg', 'err->maxSize->dflt']],
276 + 'minFileErrMsg' => ['path' => ['err->minFile->msg', 'err->minFile->dflt']],
277 + 'maxFileErrMsg' => ['path' => ['err->maxFile->msg', 'err->maxFile->dflt']],
278 + 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/file-upload'],
279 + 'classNames' => ['path' => 'customClasses'],
280 + 'attributes' => ['path' => 'customAttributes'],
281 + 'fieldName' => ['path' => 'fieldName'],
282 + 'contentId' => ['var' => 'contentId'],
283 + 'multiple' => ['path' => 'config->multiple', 'val' => false],
284 + 'allowMaxSize' => ['path' => 'config->allowMaxSize', 'val' => false],
285 + 'maxSize' => ['path' => 'config->maxSize', 'val' => 0],
286 + 'sizeUnit' => ['path' => 'config->sizeUnit', 'val' => 'KB'],
287 + 'isItTotalMax' => ['path' => 'config->isItTotalMax', 'val' => false],
288 + 'allowedFileType' => ['path' => 'config->allowedFileType', 'val' => ''],
289 + 'minFile' => ['path' => 'config->minFile', 'val' => 0],
290 + 'maxFile' => ['path' => 'config->maxFile', 'val' => 0],
291 + 'showSelectStatus' => ['path' => 'config->showSelectStatus', 'val' => false],
292 + 'fileSelectStatus' => ['path' => 'config->fileSelectStatus', 'val' => 'No File Selected'],
293 + 'oldFiles' => ['path' => 'config->oldFiles', 'val' => []],
294 + 'baseDLURL' => ['path' => 'config->baseDLURL', 'val' => ''],
295 + 'fileExistMsg' => ['val' => 'A file already exist'],
296 + 'showFileList' => ['path' => 'config->showFileList', 'val' => false],
297 + 'showFilePreview' => ['path' => 'config->showFilePreview', 'val' => false],
298 + 'showFileSize' => ['path' => 'config->showFileSize', 'val' => false],
299 + 'fileExistMsg' => ['path' => 'config->fileExistMsg', 'val' => 'A file already exist'],
195 300 ],
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' => ''],
301 + 'repeater' => [
302 + 'config' => (object) [],
303 + 'fieldKey' => ['var' => 'fieldKey'],
304 + 'fieldName' => ['path' => 'fieldName'],
305 + 'contentId' => ['var' => 'contentId'],
306 + 'showAddBtn' => ['path' => 'addBtn->show', 'val' => false],
307 + 'showAddToEndBtn' => ['path' => 'addToEndBtn->show', 'val' => false],
308 + 'defaultValue' => ['path' => 'val', 'val' => ''],
212 309 ],
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],
310 + 'rating' => [
311 + 'fieldKey' => ['var' => 'fieldKey'],
312 + 'contentId' => ['var' => 'contentId'],
313 + 'options' => ['path' => 'opt'],
314 + 'selectedRating' => ['path' => 'selectedRating'],
315 + 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
220 316 ],
221 - 'razorpay' => [
222 - 'fieldKey' => ['var' => 'fieldKey'],
223 - 'options' => ['path' => 'options'],
224 - 'payIntegID' => ['path' => 'payIntegID'],
225 - 'payType' => ['path' =>'payType', 'val' => ''],
317 + 'hcaptcha'=> [
318 + 'fieldKey' => ['var'=>'fieldKey']
226 319 ],
227 320 ];
321 + /**
322 + * Allow add-on plugins to extend field config mappings.
323 + */
324 + return apply_filters('bitform_field_config_paths', $configs);
325 + }
228 326
229 - return isset($configs[$fieldType]) ? $configs[$fieldType] : [];
327 + public static function multiStepFiles()
328 + {
329 + return [
330 + ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
331 + ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
332 + ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
333 + ['priority' => 700, 'filename' => 'bit-multi-step-form.min.js'],
334 + ];
230 335 }
231 336
232 - public static function frontendScriptFile() {
337 + public static function conversationalFormFiles()
338 + {
233 339 return [
234 - 'observeElm' => ['priority' => 101, 'filename' => 'observeElm.min.js'],
235 - 'hidden-token-field' => ['priority' => 300, 'filename' => 'hidden-token-field.min.js'],
340 + ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
341 + ['priority' => 700, 'filename' => 'bit-conversational-form.min.js'],
342 + ['priority' => 700, 'filename' => 'handleConversationalFormMsg.min.js'],
236 343 ];
237 344 }
238 345
239 - public static function validationScriptFile() {
346 + public static function frontendScriptFile()
347 + {
240 348 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
349 + 'observeElm' => ['priority' => 101, 'filename' => 'observeElm.min.js'],
350 + 'hidden-token-field' => ['priority' => 300, 'filename' => 'hidden-token-field.min.js'],
257 351 ];
258 352 }
259 353
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 - ],
354 + public static function validationAndOtherScriptFile()
355 + {
356 + $files = [
357 + 'confirmFldMatch' => ['priority' => 701, 'filename' => 'confirmFldMatch.min.js'],
358 + 'checkFldValidation' => ['priority' => 701, 'filename' => 'checkFldValidation.min.js'],
359 + // 'checkMinMaxOptions' => ['priority' => 702, 'filename' => 'checkMinMaxOptions.min.js'],
360 + // 'bfDatetimeFldValidation' => ['priority' => 702, 'filename' => 'bfDatetimeFldValidation.min.js'],
361 + 'bfParseDateTime' => ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
362 + 'checkMinMaxValue' => ['priority' => 702, 'filename' => 'checkMinMaxValue.min.js'],
363 + 'textLengthValidation' => ['priority' => 702, 'filename' => 'textLengthValidation.min.js'],
364 + 'customOptionValidation' => ['priority' => 702, 'filename' => 'customOptionValidation.min.js'],
365 + 'dcsnbxFldValidation' => ['priority' => 702, 'filename' => 'dcsnbxFldValidation.min.js'],
366 + 'emailFldValidation' => ['priority' => 702, 'filename' => 'emailFldValidation.min.js'],
367 + 'fileupFldValidation' => ['priority' => 702, 'filename' => 'fileupFldValidation.min.js'],
368 + 'advanceFileupFldValidation' => ['priority' => 702, 'filename' => 'advanceFileUpFldValidation.min.js'],
369 + 'phoneNumberFldValidation' => ['priority' => 702, 'filename' => 'phoneNumberFldValidation.min.js'],
370 + 'currencyFldValidation' => ['priority' => 702, 'filename' => 'currencyFldValidation.min.js'],
371 + 'addressZipFldValidation' => ['priority' => 702, 'filename' => 'addressZipFldValidation.min.js'],
372 + 'generateBackslashPattern' => ['priority' => 700, 'filename' => 'generateBackslashPattern.min.js'],
373 + // 'nmbrFldValidation' => ['priority' => 702, 'filename' => 'nmbrFldValidation.min.js'],
374 + 'nmbrBadInputValidation' => ['priority' => 702, 'filename' => 'nmbrBadInputValidation.min.js'],
375 + // 'regexPatternValidation' => ['priority' => 701, 'filename' => 'regexPatternValidation.min.js'], // load before generateBackslashPattern file, then load regexPatternValidation
376 + 'inputMaskValidation' => ['priority' => 701, 'filename' => 'inputMaskValidation.min.js'], // load before generateBackslashPattern file, then load inputMaskValidation
377 + 'bit-input-mask' => ['priority' => 701, 'filename' => 'bit-input-mask.min.js'], // load before generateBackslashPattern file, then load bit-input-mask
378 + 'setBitInputMaskToInput' => ['priority' => 702, 'filename' => 'setBitInputMaskToInput.min.js'], // load before generateBackslashPattern file, then load setBitInputMaskToInput
379 + 'requiredFldValidation' => ['priority' => 700, 'filename' => 'requiredFldValidation.min.js'],
380 + 'urlFldValidation' => ['priority' => 702, 'filename' => 'urlFldValidation.min.js'],
381 + 'validation' => ['priority' => 705, 'filename' => 'validateForm.min.js'], // last priority for validation script
382 + 'conditionalLogic' => ['priority' => 705, 'filename' => 'bit-conditionals.min.js'], // last priority for validation script
383 + 'resetPlaceholders' => ['priority' => 201, 'filename' => 'resetPlaceholders.min.js'],
384 + 'bfResetDefaultValue' => ['priority' => 201, 'filename' => 'bfResetDefaultValue.min.js'],
385 + 'validateFocusLost' => ['priority' => 706, 'filename' => 'validate-focus.min.js'], // last priority for validation script
270 386 ];
271 387
272 - return $commonFunctions;
388 + /**
389 + * Allow add-on plugins to register additional validation scripts.
390 + */
391 + return apply_filters('bitform_validation_and_other_script_files', $files);
273 392 }
274 393
275 - public static function validationScriptFileMapping($fieldType) {
276 - $textTypeField = ['text', 'password', 'username', 'url', 'date', 'datetime-local', 'time', 'month', 'week', 'color'];
394 + public static function validationScriptFileMapping($fieldType)
395 + {
396 + // Pro filter callbacks type-hint string; never let null/non-string through.
397 + $fieldType = is_string($fieldType) ? $fieldType : '';
398 + $textTypeField = ['text', 'password', 'username', 'color'];
277 399 if (in_array($fieldType, $textTypeField)) {
278 400 $fieldType = 'text';
279 401 }
280 402 $fields =
@@ -279,15 +401,53 @@
279 401 }
280 402 $fields =
281 403 [
282 404 'text' => [
283 - 'regexPatternValidation' => [
284 - 'paths' => ['valid->regexr'],
405 + 'bit-input-mask' => [
406 + 'paths' => ['valid->inputMask'],
407 + ],
408 + 'inputMaskValidation' => [
409 + 'paths' => ['valid->inputMask'],
285 410 'dependencies' => [
286 - 'generateBackslashPattern'
411 + 'generateBackslashPattern',
412 + 'validation',
287 413 ]
414 + ],
415 + 'setBitInputMaskToInput' => [
416 + 'paths' => ['valid->inputMask'],
417 + 'dependencies' => [
418 + 'bit-input-mask'
419 + ]
420 + ],
421 + 'textLengthValidation' => [
422 + 'paths' => ['valid->minlength', 'valid->maxlength', 'valid->minword', 'valid->maxword']
423 + ],
424 + 'confirmFldMatch' => [
425 + 'paths' => ['parentFieldKey'],
288 426 ]
427 +
289 428 ],
429 + 'textarea' => [
430 + 'bit-input-mask' => [
431 + 'paths' => ['valid->inputMask'],
432 + ],
433 + 'inputMaskValidation' => [
434 + 'paths' => ['valid->inputMask'],
435 + 'dependencies' => [
436 + 'generateBackslashPattern',
437 + 'validation',
438 + ]
439 + ],
440 + 'setBitInputMaskToInput' => [
441 + 'paths' => ['valid->inputMask'],
442 + 'dependencies' => [
443 + 'bit-input-mask'
444 + ]
445 + ],
446 + 'textLengthValidation' => [
447 + 'paths' => ['valid->minlength', 'valid->maxlength', 'valid->minword', 'valid->maxword']
448 + ]
449 + ],
290 450 'email' => [
291 451 'emailFldValidation' => [
292 452 'paths' => ['err->invalid->show'],
293 453 'dependencies' => [
@@ -293,43 +453,46 @@
293 453 'dependencies' => [
294 454 'generateBackslashPattern'
295 455 ]
296 456 ],
457 + 'confirmFldMatch' => [
458 + 'paths' => ['parentFieldKey'],
459 + ]
297 460 ],
298 461 'number' => [
299 462 'nmbrFldValidation' => [
300 463 'paths' => ['mn', 'mx']
464 + ],
465 + 'nmbrBadInputValidation' => [
466 + 'paths' => ['err->invalid->show']
301 467 ]
302 468 ],
303 - 'radio' => [
304 - 'customOptionValidation' => [
305 - 'paths' => ['valid->otherOptReq'],
469 + 'range' => [
470 + 'checkMinMaxValue' => [
471 + 'paths' => ['mn', 'mx']
306 472 ]
307 473 ],
308 - 'check' => [
309 - 'checkMinMaxOptions' => [
310 - 'paths' => ['mn', 'mx'],
474 + 'url' => [
475 + 'urlFldValidation' => [
476 + 'paths' => ['err->invalid->show'],
311 477 'dependencies' => [
312 - 'checkFldValidation'
478 + 'generateBackslashPattern'
313 479 ]
314 480 ],
315 - 'customOptionValidation' => [
316 - 'paths' => ['valid->otherOptReq'],
317 - ]
318 - ],
319 - 'select' => [
320 - 'checkMinMaxOptions' => [
321 - 'paths' => ['mn', 'mx'],
481 + 'bit-input-mask' => [
482 + 'paths' => ['valid->inputMask'],
483 + ],
484 + 'inputMaskValidation' => [
485 + 'paths' => ['valid->inputMask'],
322 486 'dependencies' => [
323 - 'checkFldValidation'
487 + 'generateBackslashPattern',
488 + 'validation',
324 489 ]
325 490 ],
326 - ],
327 - 'url' => [
328 - 'urlFldValidation' => [
329 - 'paths' => ['err->invalid->show'],
491 + 'setBitInputMaskToInput' => [
492 + 'paths' => ['valid->inputMask'],
330 493 'dependencies' => [
331 - 'generateBackslashPattern'
494 + 'bit-input-mask'
332 495 ]
333 496 ]
334 497 ],
335 498 'decision-box' => [
@@ -336,15 +499,15 @@
336 499 'dcsnbxFldValidation' => [
337 500 'paths' => ['valid->req']
338 501 ]
339 502 ],
340 - 'file-up' => [
341 - 'fileupFldValidation' => [
503 + 'gdpr' => [
504 + 'dcsnbxFldValidation' => [
342 505 'paths' => ['valid->req']
343 506 ]
344 507 ],
345 - 'advanced-file-up' => [
346 - 'advanceFileupFldValidation' => [
508 + 'file-up' => [
509 + 'fileupFldValidation' => [
347 510 'paths' => ['valid->req']
348 511 ]
349 512 ],
350 513 'phone-number' => [
@@ -351,8 +514,21 @@
351 514 'phoneNumberFldValidation' => [
352 515 'paths' => ['err->invalid->show'],
353 516 ]
354 517 ],
518 + 'address' => [
519 + 'addressZipFldValidation' => [
520 + 'paths' => ['config->zipValidation'],
521 + 'dependencies' => [
522 + 'validation',
523 + ]
524 + ]
525 + ],
355 526 ];
356 - return isset($fields[$fieldType]) ? $fields[$fieldType] : [];
527 + $mapping = isset($fields[$fieldType]) ? $fields[$fieldType] : [];
528 +
529 + /**
530 + * Allow pro add-ons to extend/override mapping per field type.
531 + */
532 + return apply_filters('bitform_field_validation_script_file_mapping', $mapping, $fieldType);
357 533 }
358 534 }