PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
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/Integration/IntegrationHandler.php +87 -2 2.10.22.15.3 View file →
@@ -218,11 +218,26 @@
218 218 preg_match_all($fieldPattern, $stringToReplaceField, $matchedField);
219 219 $uniqueFieldsInStr = array_unique($matchedField[0]);
220 220 foreach ($uniqueFieldsInStr as $key => $value) {
221 221 $fieldName = substr($value, 2, strlen($value) - 3);
222 +
223 + $repeaterArr = explode('.', $fieldName);
224 +
222 225 if (isset($fieldValues[$fieldName])) {
223 - $stringToReplaceField = is_string($fieldValues[$fieldName]) ? str_replace($value, $fieldValues[$fieldName], $stringToReplaceField) :
224 - wp_json_encode($fieldValues[$fieldName]);
226 + $stringToReplaceField = is_string($fieldValues[$fieldName])
227 + ? str_replace($value, $fieldValues[$fieldName], $stringToReplaceField)
228 + : wp_json_encode($fieldValues[$fieldName]);
229 + } elseif (2 === count($repeaterArr) && isset($fieldValues[$repeaterArr[0]])) {
230 + $repeaterValues = [];
231 + $repeaterFieldValues = $fieldValues[$repeaterArr[0]];
232 +
233 + foreach ($repeaterFieldValues as $value) {
234 + if (isset($value[$repeaterArr[1]])) {
235 + $repeaterValues[] = $value[$repeaterArr[1]];
236 + }
237 + }
238 +
239 + $stringToReplaceField = $repeaterValues;
225 240 }
226 241 }
227 242 return $stringToReplaceField;
228 243 }
@@ -393,6 +408,76 @@
393 408 $queueuEntry,
394 409 ];
395 410 }
396 411 return $responseData;
412 + }
413 +
414 + public static function repeaterFieldValueFormatter($fieldValues)
415 + {
416 + $formattedArray = [];
417 +
418 + foreach ($fieldValues as $key => $value) {
419 + if (is_array($value)) {
420 + foreach ($value as $index => $v) {
421 + if (is_array($v)) {
422 + foreach ($v as $k1 => $v1) {
423 + $formattedArray[$k1][] = $v1;
424 + }
425 + } else {
426 + $formattedArray[$key][] = $v;
427 + }
428 + }
429 + } else {
430 + $formattedArray[$key] = $value;
431 + }
432 + }
433 +
434 + return $formattedArray;
435 + }
436 +
437 + /**
438 + *
439 + * @param mixed $fieldValues
440 + * @param mixed $returnRepeaterValue default is array
441 + * @return array and repeater field value as array or string
442 + */
443 + public static function formattedRepeaterValue($fieldValues, $returnRepeaterValue = '')
444 + {
445 + // get the repeater field and store it in an array
446 + $repeaterField = [];
447 + foreach ($fieldValues as $key => $value) {
448 + if (!preg_match('/\./', $key)) {
449 + continue;
450 + }
451 + $repeaterField[] = $key;
452 + }
453 +
454 + // put the value of the child key to the parent repeater field
455 + foreach ($repeaterField as $key) {
456 + list($parentKey, $childKey) = explode('.', $key);
457 + $repeatValues = $fieldValues[$parentKey];
458 +
459 + if (!is_array($repeatValues)) {
460 + continue;
461 + }
462 +
463 + foreach ($repeatValues as $value) {
464 + if (isset($value[$childKey])) {
465 + if (!isset($fieldValues[$key]) || !is_array($fieldValues[$key])) {
466 + $fieldValues[$key] = [];
467 + }
468 + if (!empty($value[$childKey])) {
469 + $fieldValues[$key][] = $value[$childKey];
470 + }
471 + }
472 + }
473 + }
474 +
475 + // convert the array to string repeater field value
476 + if ('string' === $returnRepeaterValue) {
477 + foreach ($repeaterField as $key) {
478 + $fieldValues[$key] = implode(', ', $fieldValues[$key]);
479 + }
480 + }
481 + return $fieldValues;
397 482 }
398 483 }