PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.21.4
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.21.4
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/Core/Fallback/Field.php +60 -4 2.02.21.4 View file →
@@ -4,10 +4,12 @@
4 4
5 5 use BitCode\BitForm\Admin\Form\AdminFormHandler;
6 6 use BitCode\BitForm\Core\Database\FormModel;
7 7
8 -class Field {
9 - public function buttonValidsObject() {
8 +class Field
9 +{
10 + public function buttonValidsObject()
11 + {
10 12 $formModel = new FormModel();
11 13 $forms = $formModel->get(
12 14 ['id', 'form_content']
13 15 );
@@ -38,9 +40,10 @@
38 40 }
39 41 }
40 42 }
41 43
42 - public function addButton() {
44 + public function addButton()
45 + {
43 46 // if version is lower or equal than 1.3.13
44 47 $formModel = new FormModel();
45 48 $forms = $formModel->get(
46 49 ['id', 'form_content'],
@@ -52,9 +55,9 @@
52 55 $adminFormHandler = new AdminFormHandler();
53 56 foreach ($forms as $form) {
54 57 $formID = $form->id;
55 58 $formContent = json_decode($form->form_content);
56 - $fields = json_encode($formContent->fields);
59 + $fields = wp_json_encode($formContent->fields);
57 60 if (isset($formContent->buttons)) {
58 61 if (false === strpos($fields, '"btnTyp":"submit"')) {
59 62 $align = isset($formContent->buttons->align) ? $formContent->buttons->align : 'right';
60 63 $btnSiz = isset($formContent->buttons->btnSiz) ? $formContent->buttons->btnSiz : 'md';
@@ -197,8 +200,61 @@
197 200 'id' => $formID,
198 201 ]
199 202 );
200 203 }
204 + }
205 + }
206 + }
207 +
208 + public function phoneNumberMissingPattern()
209 + {
210 + $formModel = new FormModel();
211 + $forms = $formModel->get(
212 + ['id', 'form_content']
213 + );
214 +
215 + if (!is_wp_error($forms)) {
216 + $missingPatterns = [
217 + 'CA' => '(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]$_bf_$d{6}',
218 + 'CL' => '2(?:1982[0-6]|3314[05-9])$_bf_$d{3}|(?:2(?:1(?:160|962)|3(?:2$_bf_$d$_bf_$d|3(?:[03467]$_bf_$d|1[0-35-9]|2[1-9]|5[0-24-9]|8[0-3])|600)|646[59])|80[1-9]$_bf_$d$_bf_$d|9(?:3(?:[0-57-9]$_bf_$d$_bf_$d|6(?:0[02-9]|[1-9]$_bf_$d))|6(?:[0-8]$_bf_$d$_bf_$d|9(?:[02-79]$_bf_$d|1[05-9]))|7[1-9]$_bf_$d$_bf_$d|9(?:[03-9]$_bf_$d$_bf_$d|1(?:[0235-9]$_bf_$d|4[0-24-9])|2(?:[0-79]$_bf_$d|8[0-46-9]))))$_bf_$d{4}|(?:22|3[2-5]|[47][1-35]|5[1-3578]|6[13-57]|8[1-9]|9[2458])$_bf_$d{7}',
219 + 'DK' => '(?:[2-7]$_bf_$d|8[126-9]|9[1-46-9])$_bf_$d{6}',
220 + 'GU' => '671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[02-46-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))$_bf_$d{4}',
221 + 'MP' => '670(?:2(?:3[3-7]|56|8[4-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)$_bf_$d{4}',
222 + 'PR' => '(?:787|939)[2-9]$_bf_$d{6}',
223 + 'US' => '5056(?:[0-35-9]$_bf_$d|4[46])$_bf_$d{4}|(?:4722|505[2-57-9])$_bf_$d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[01356]|3[0-24679]|4[167]|5[0-2]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]$_bf_$d{6}',
224 + 'VI' => '340(?:2(?:0[0-368]|2[06-8]|4[49]|77)|3(?:32|44)|4(?:2[23]|44|7[34]|89)|5(?:1[34]|55)|6(?:2[56]|4[23]|77|9[023])|7(?:1[2-57-9]|2[57]|7$_bf_$d)|884|998)$_bf_$d{4}'
225 + ];
226 +
227 + foreach ($forms as $form) {
228 + $formID = $form->id;
229 + $formContent = json_decode($form->form_content);
230 + $fields = $formContent->fields;
231 +
232 + foreach ($fields as $fldKey => $fldData) {
233 + if ('phone-number' === $fldData->typ) {
234 + $options = $fldData->options;
235 + $optCount = count($options);
236 + for ($i = 0; $i < $optCount; $i++) {
237 + $opt = $options[$i];
238 + if (!isset($opt->ptrn) && isset($missingPatterns[$opt->i])) {
239 + $options[$i]->ptrn = $missingPatterns[$opt->i];
240 + }
241 + }
242 + $fldData->options = $options;
243 + $fields->{$fldKey} = $fldData;
244 + }
245 + }
246 +
247 + $formContent->fields = $fields;
248 +
249 + $formModel->update(
250 + [
251 + 'form_content' => wp_json_encode($formContent),
252 + ],
253 + [
254 + 'id' => $formID,
255 + ]
256 + );
201 257 }
202 258 }
203 259 }
204 260 }