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/Frontend/Form/View/Conversational/Fields/HtmlSelectField.php +103 -58 2.10.0 → V3.3.2 View file →
@@ -19,9 +19,9 @@
19 19 if (isset($opt->val) && $opt->val === $val) {
20 20 $selected = 'selected';
21 21 } elseif (isset($opt->lbl) && $opt->lbl === $val) {
22 22 $selected = 'selected';
23 - } elseif (property_exists($opt, 'check')) {
23 + } elseif (is_object($opt) && property_exists($opt, 'check')) {
24 24 $selected = 'selected';
25 25 }
26 26 return $selected;
27 27 }
@@ -31,8 +31,10 @@
31 31 $fieldHelpers = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map);
32 32 $disabled = $fieldHelpers->disabled();
33 33 $readonly = $fieldHelpers->readonly();
34 34 $name = $fieldHelpers->name();
35 + $ariaDescribedBy = $fieldHelpers->ariaDescribedBy();
36 + $ariaRequired = $fieldHelpers->ariaRequired();
35 37 $value = '';
36 38 if ($val) {
37 39 $value = $val;
38 40 } elseif (isset($field->val)) {
@@ -44,83 +46,126 @@
44 46 $optionsHTML = '';
45 47 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
46 48 $contentCount = count($bfFrontendFormIds);
47 49 if ($fieldHelpers->property_exists_nested($field, 'phHide', true)) {
48 - $phHide = <<<PHHIDE
49 - <option
50 - {$fieldHelpers->getCustomAttributes('slct-optn')}
51 - class="{$fieldHelpers->getConversationalCls('slct-optn')} {$fieldHelpers->getCustomClasses('slct-optn')}"
50 + $phHide = sprintf(
51 + '<option
52 + %1$s
53 + class="%2$s"
52 54 value
53 55 >
54 - {$fieldHelpers->kses_post($field->ph)}
55 - </option>
56 -PHHIDE;
56 + %3$s
57 + </option>',
58 + $fieldHelpers->getCustomAttributes('slct-optn'),
59 + $fieldHelpers->getConversationalCls('slct-optn') . ' ' . $fieldHelpers->getCustomClasses('slct-optn'),
60 + $fieldHelpers->kses_post($field->ph)
61 + );
57 62 }
58 63
59 - if (property_exists($field, 'opt')) {
64 + if (property_exists($field, 'opt') && is_iterable($field->opt)) {
60 65 foreach ($field->opt as $opt) {
66 + if (!is_object($opt)) {
67 + continue;
68 + }
61 69 $disabled = property_exists($opt, 'disabled') ? 'disabled' : '';
62 70 if (property_exists($opt, 'type')) {
63 - $optionsHTML .= <<<OPTGRP
64 - <optgroup
65 - {$fieldHelpers->getCustomAttributes('slct-opt-grp')}
66 - class="{$fieldHelpers->getConversationalCls('slct-opt-grp')} {$fieldHelpers->getCustomClasses('slct-opt-grp')}"
67 - label="{$fieldHelpers->esc_attr($opt->title)}"
68 - {$disabled}
69 - >
70 -OPTGRP;
71 - foreach ($opt->childs as $child) {
72 - $val = isset($child->val) ? $child->val : $child->lbl;
71 + $optionsHTML .= sprintf(
72 + '<optgroup
73 + %1$s
74 + class="%2$s"
75 + label="%3$s"
76 + %4$s
77 + >',
78 + $fieldHelpers->getCustomAttributes('slct-opt-grp'),
79 + $fieldHelpers->getConversationalCls('slct-opt-grp') . ' ' . $fieldHelpers->getCustomClasses('slct-opt-grp'),
80 + $fieldHelpers->esc_attr($opt->title),
81 + $disabled
82 + );
83 + $optChilds = isset($opt->childs) && is_iterable($opt->childs) ? $opt->childs : [];
84 + foreach ($optChilds as $child) {
85 + if (!is_object($child)) {
86 + continue;
87 + }
88 + $val = isset($child->val) ? $child->val : ($child->lbl ?? '');
73 89 $selected = self::checkSelected($child, $value);
74 90 $disabled = property_exists($child, 'disabled') ? 'disabled' : '';
75 - $optionsHTML .= <<<OPT
76 - <option
77 - {$fieldHelpers->getCustomAttributes('slct-optn')}
78 - class="{$fieldHelpers->getConversationalCls('slct-optn')} {$fieldHelpers->getCustomClasses('slct-optn')}"
79 - value="{$fieldHelpers->esc_attr($val)}"
80 - {$selected}
81 - {$disabled}
91 + $optionsHTML .= sprintf(
92 + '<option
93 + %1$s
94 + class="%2$s"
95 + value="%3$s"
96 + %4$s
97 + %5$s
82 98 >
83 - {$fieldHelpers->kses_post($child->lbl)}
84 - </option>
85 -OPT;
99 + %6$s
100 + </option>',
101 + $fieldHelpers->getCustomAttributes('slct-optn'),
102 + $fieldHelpers->getConversationalCls('slct-optn') . ' ' . $fieldHelpers->getCustomClasses('slct-optn'),
103 + $fieldHelpers->esc_attr($val),
104 + $selected,
105 + $disabled,
106 + $fieldHelpers->kses_post($child->lbl)
107 + );
86 108 }
87 109 $optionsHTML .= '</optgroup>';
88 110 } else {
89 111 $selected = self::checkSelected($opt, $value);
90 - $val = isset($opt->val) ? $opt->val : $opt->lbl;
91 - $optionsHTML .= <<<OPT
92 - <option
93 - {$fieldHelpers->getCustomAttributes('slct-optn')}
94 - class="{$fieldHelpers->getConversationalCls('slct-optn')} {$fieldHelpers->getCustomClasses('slct-optn')}"
95 - value="{$fieldHelpers->esc_attr($val)}"
96 - {$selected}
97 - {$disabled}
112 + $val = isset($opt->val) ? $opt->val : ($opt->lbl ?? '');
113 + $optionsHTML .= sprintf(
114 + '<option
115 + %1$s
116 + class="%2$s"
117 + value="%3$s"
118 + %4$s
119 + %5$s
98 120 >
99 - {$fieldHelpers->kses_post($opt->lbl)}
100 - </option>
101 -OPT;
121 + %6$s
122 + </option>',
123 + $fieldHelpers->getCustomAttributes('slct-optn'),
124 + $fieldHelpers->getConversationalCls('slct-optn') . ' ' . $fieldHelpers->getCustomClasses('slct-optn'),
125 + $fieldHelpers->esc_attr($val),
126 + $selected,
127 + $disabled,
128 + $fieldHelpers->kses_post($opt->lbl)
129 + );
102 130 }
103 131 }
104 132 }
105 133
106 - return <<<HTMLSELECTFIELD
107 - <div
108 - {$fieldHelpers->getCustomAttributes('inp-fld-wrp')}
109 - class="{$fieldHelpers->getConversationalCls('inp-fld-wrp')} {$fieldHelpers->getCustomClasses('inp-fld-wrp')}"
110 - >
111 - <select
112 - {$fieldHelpers->getCustomAttributes('fld')}
113 - id="{$rowID}-{$contentCount}"
114 - class="{$fieldHelpers->getConversationalCls('fld')} {$fieldHelpers->getCustomClasses('fld')} {$readonlyCls}"
115 - {$readonly}
116 - {$disabled}
117 - {$name}
118 - value="{$fieldHelpers->esc_attr($value)}"
134 + return sprintf(
135 + '<div
136 + %1$s
137 + class="%2$s"
119 138 >
120 - {$phHide}
121 - {$optionsHTML}
122 - </select>
123 - </div>
124 -HTMLSELECTFIELD;
139 + <select
140 + %3$s
141 + id="%4$s-%5$s"
142 + class="%6$s %7$s"
143 + %8$s
144 + %9$s
145 + %10$s
146 + %11$s
147 + %12$s
148 + value="%13$s"
149 + >
150 + %14$s
151 + %15$s
152 + </select>
153 + </div>',
154 + $fieldHelpers->getCustomAttributes('inp-fld-wrp'),
155 + $fieldHelpers->getConversationalCls('inp-fld-wrp') . ' ' . $fieldHelpers->getCustomClasses('inp-fld-wrp'),
156 + $fieldHelpers->getCustomAttributes('fld'),
157 + $rowID,
158 + $contentCount,
159 + $fieldHelpers->getConversationalCls('fld') . ' ' . $fieldHelpers->getCustomClasses('fld'),
160 + $readonlyCls,
161 + $ariaRequired,
162 + $ariaDescribedBy,
163 + $readonly,
164 + $disabled,
165 + $name,
166 + $fieldHelpers->esc_attr($value),
167 + $phHide,
168 + $optionsHTML
169 + );
125 170 }
126 171 }