PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Common / Helpers / Import / GravityFormsSubmitLabelMapper.php

GravityFormsSubmitLabelMapper.php in The Innovative Form Builder – IvyForms 1.5, at backend/src/Common/Helpers/Import/GravityFormsSubmitLabelMapper.php

42 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Common\Helpers\Import;
4
5 use IvyForms\Services\Translations\BackendStrings;
6
7 /**
8 * Read Gravity Forms submit copy for IvyForms button settings.
9 */
10 class GravityFormsSubmitLabelMapper
11 {
12 /**
13 * Gravity stores submit copy on form.button.text. Empty values still show as
14 * "Submit" in the Gravity editor, and some exports only keep the text on the
15 * submit field label.
16 *
17 * @param array<string, mixed> $formRaw
18 * @return string
19 */
20 public static function extract(array $formRaw): string
21 {
22 $button = is_array($formRaw['button'] ?? null) ? $formRaw['button'] : [];
23 $label = sanitize_text_field((string) ($button['text'] ?? ''));
24 if ($label !== '') {
25 return $label;
26 }
27
28 foreach (($formRaw['fields'] ?? []) as $rawField) {
29 if (!is_array($rawField) || ($rawField['type'] ?? '') !== 'submit') {
30 continue;
31 }
32
33 $label = sanitize_text_field((string) ($rawField['label'] ?? ''));
34 if ($label !== '') {
35 return $label;
36 }
37 }
38
39 return BackendStrings::getCommonStrings()['submit'];
40 }
41 }
42