PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
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/Frontend/Form/View/Conversational/Fields/CheckBoxField.php +100 -83 2.10.03.3.1 View file →
@@ -18,13 +18,16 @@
18 18 $fieldHelpers = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map);
19 19
20 20 $req = $fieldHelpers->required();
21 21 $name = $fieldHelpers->name();
22 + $ariaDescribedBy = $fieldHelpers->ariaDescribedBy();
23 + $ariaRequired = $fieldHelpers->ariaRequired();
24 + $labelId = $fieldHelpers->getLabelId();
22 25 $checkBoxOptions = '';
23 26 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
24 27 $contentCount = count($bfFrontendFormIds);
25 28
26 - if (property_exists($field, 'opt') && count($field->opt) > 0) {
29 + if (is_object($field) && property_exists($field, 'opt') && is_countable($field->opt) && count($field->opt) > 0) {
27 30 if (isset($field->val) && false !== strpos($field->val, BITFORMS_BF_SEPARATOR)) {
28 31 $defaultValues = explode(BITFORMS_BF_SEPARATOR, $field->val);
29 32 } else {
30 33 $defaultValues = isset($field->val) ? explode(',', $field->val) : [];
@@ -45,123 +48,137 @@
45 48 }
46 49 if ($fieldHelpers->property_exists_nested($opt, 'req', true)) {
47 50 $req = 'required';
48 51 }
49 - if ($fieldHelpers->property_exists_nested($field, 'valid->disabled', true)
50 - || $fieldHelpers->property_exists_nested($opt, 'disabled', true)) {
52 + if (
53 + $fieldHelpers->property_exists_nested($field, 'valid->disabled', true)
54 + || $fieldHelpers->property_exists_nested($opt, 'disabled', true)
55 + ) {
51 56 $disabled = "disabled='disabled'";
52 57 }
53 58
54 - $checkBoxOptions .= <<<CHECKBOXOPTIONS
55 - <div
56 - {$fieldHelpers->getCustomAttributes('cw')}
57 - class="{$fieldHelpers->getConversationalCls('cw')} {$fieldHelpers->getCustomClasses('cw')}"
58 - >
59 - <input
60 - id="{$rowID}-{$contentCount}-chk-{$key}"
61 - type="checkbox"
62 - class="{$fieldHelpers->getConversationalCls('ci')} {$fieldHelpers->getCustomClasses('ci')}"
63 - {$disabled}
64 - value="{$value}"
65 - {$check}
66 - {$req}
67 - {$name}
68 - />
69 -
70 - <label
71 - {$fieldHelpers->getCustomAttributes('cl')}
72 - data-cl
73 - for="{$rowID}-{$contentCount}-chk-{$key}"
74 - class="{$fieldHelpers->getConversationalCls('cl')} {$fieldHelpers->getCustomClasses('cl')}"
59 + $checkBoxOptions .=
60 + '<div
61 + ' . $fieldHelpers->getCustomAttributes('cw') . '
62 + class="' . $fieldHelpers->getConversationalCls('cw') . ' ' . $fieldHelpers->getCustomClasses('cw') . '"
75 63 >
76 -
77 - <span
78 - {$fieldHelpers->getCustomAttributes('bx')}
79 - data-bx
80 - class="{$fieldHelpers->getConversationalCls('bx')} {$fieldHelpers->getCustomClasses('bx')}"
81 - >
82 - <span class="{$fieldHelpers->getConversationalCls('opt-key-lbl')}">Key</span>
83 - <span class="{$fieldHelpers->getConversationalCls('opt-key')}">{$keyChar}</span>
84 - </span>
85 - <span
86 - {$fieldHelpers->getCustomAttributes('ct')}
87 - class="{$fieldHelpers->getConversationalCls('ct')} {$fieldHelpers->getCustomClasses('ct')}"
88 - >
89 - {$fieldHelpers->kses_post($fieldHelpers->renderHTMR($opt->lbl))}
90 - </span>
91 - </label>
92 - </div>
93 -CHECKBOXOPTIONS;
64 + <input
65 + id="' . $rowID . '-' . $contentCount . '-chk-' . $key . '"
66 + type="checkbox"
67 + class="' . $fieldHelpers->getConversationalCls('ci') . ' ' . $fieldHelpers->getCustomClasses('ci') . '"
68 + ' . $disabled . '
69 + value="' . $value . '"
70 + ' . $check . '
71 + ' . $req . '
72 + ' . $name . '
73 + />
74 +
75 + <label
76 + ' . $fieldHelpers->getCustomAttributes('cl') . '
77 + data-cl
78 + for="' . $rowID . '-' . $contentCount . '-chk-' . $key . '"
79 + class="' . $fieldHelpers->getConversationalCls('cl') . ' ' . $fieldHelpers->getCustomClasses('cl') . '"
80 + >
81 + <span
82 + ' . $fieldHelpers->getCustomAttributes('bx') . '
83 + data-bx
84 + class="' . $fieldHelpers->getConversationalCls('bx') . ' ' . $fieldHelpers->getCustomClasses('bx') . '"
85 + >
86 + <span class="' . $fieldHelpers->getConversationalCls('opt-key-lbl') . '">Key</span>
87 + <span class="' . $fieldHelpers->getConversationalCls('opt-key') . '">' . $keyChar . '</span>
88 + </span>
89 + <span
90 + ' . $fieldHelpers->getCustomAttributes('ct') . '
91 + class="' . $fieldHelpers->getConversationalCls('ct') . ' ' . $fieldHelpers->getCustomClasses('ct') . '"
92 + >
93 + ' . $fieldHelpers->kses_post($fieldHelpers->renderHTMR($opt->lbl)) . '
94 + </span>
95 + </label>
96 + </div>
97 +';
94 98 }
95 99 }
96 100
97 101 //Other Option
98 - $optCount = property_exists($field, 'opt') ? count($field->opt) : 0;
102 + $optCount = isset($field->opt) && is_countable($field->opt) ? count($field->opt) : 0;
103 + $otherOptLbl = !empty($field->otherOptLbl) ? $field->otherOptLbl : __('Other...', 'bit-form');
99 104 $inputPh = isset($field->otherInpPh) ? "placeholder='{$fieldHelpers->esc_attr($field->otherInpPh)}'" : "placeholder='Other...'";
100 105 $inpReq = isset($field->valid->otherOptReq) ? ($field->valid->otherOptReq ? 'required' : '') : '';
101 106 if (property_exists($field, 'addOtherOpt') && $field->addOtherOpt) {
102 107 $keyChar = chr(65 + count($field->opt));
103 - $checkBoxOptions .= <<<CHECKBOXOPTIONS
104 - <div
105 - {$fieldHelpers->getCustomAttributes('cw')}
106 - class="{$fieldHelpers->getConversationalCls('cw')} {$fieldHelpers->getCustomClasses('cw')}"
108 + $checkBoxOptions .=
109 + ' <div
110 + ' . $fieldHelpers->getCustomAttributes('cw') . '
111 + class="' . $fieldHelpers->getConversationalCls('cw') . ' ' . $fieldHelpers->getCustomClasses('cw') . '"
107 112 >
108 113 <input
109 - id="{$rowID}-{$contentCount}-chk-{$optCount}"
110 - data-oopt="{$rowID}"
114 + id="' . $rowID . '-' . $contentCount . '-chk-' . $optCount . '"
115 + data-oopt="' . $rowID . '"
111 116 type="checkbox"
112 - class="{$fieldHelpers->getConversationalCls('ci')} {$fieldHelpers->getCustomClasses('ci')}"
113 - {$disabled}
117 + class="' . $fieldHelpers->getConversationalCls('ci') . ' ' . $fieldHelpers->getCustomClasses('ci') . '"
118 + ' . $disabled . '
114 119 value=""
115 - {$name}
120 + ' . $name . '
116 121 />
117 122 <label
118 - {$fieldHelpers->getCustomAttributes('cl')}
123 + ' . $fieldHelpers->getCustomAttributes('cl') . '
119 124 data-cl
120 - for="{$rowID}-{$contentCount}-chk-{$optCount}"
121 - class="{$fieldHelpers->getConversationalCls('cl')} {$fieldHelpers->getCustomClasses('cl')}"
125 + for="' . $rowID . '-' . $contentCount . '-chk-' . $optCount . '"
126 + class="' . $fieldHelpers->getConversationalCls('cl') . ' ' . $fieldHelpers->getCustomClasses('cl') . '"
122 127 >
123 128 <span
124 - {$fieldHelpers->getCustomAttributes('ck')}
129 + ' . $fieldHelpers->getCustomAttributes('ck') . '
125 130 data-bx
126 - class="{$fieldHelpers->getConversationalCls('bx')} {$fieldHelpers->getConversationalCls('ck')} {$fieldHelpers->getCustomClasses('ck')}"
131 + class="' . $fieldHelpers->getConversationalCls('bx') . ' ' . $fieldHelpers->getConversationalCls('ck') . ' ' . $fieldHelpers->getCustomClasses('ck') . '"
127 132 >
128 - <span class="{$fieldHelpers->getConversationalCls('opt-key')}">{$keyChar}</span>
133 + <span class="' . $fieldHelpers->getConversationalCls('opt-key') . '">' . $keyChar . '</span>
129 134 </span>
130 135 <span
131 - {$fieldHelpers->getCustomAttributes('ct')}
132 - class="{$fieldHelpers->getConversationalCls('ct')} {$fieldHelpers->getCustomClasses('ct')}"
136 + ' . $fieldHelpers->getCustomAttributes('ct') . '
137 + class="' . $fieldHelpers->getConversationalCls('ct') . ' ' . $fieldHelpers->getCustomClasses('ct') . '"
133 138 >
134 - Other..
139 + ' . $otherOptLbl . '
135 140 </span>
136 141 </label>
137 - <div data-oinp-wrp class="{$fieldHelpers->getConversationalCls('other-inp-wrp')}">
142 + <div data-oinp-wrp class="' . $fieldHelpers->getConversationalCls('other-inp-wrp') . '">
138 143 <input
139 - data-bf-other-inp='{$rowID}-chk-{$optCount}'
144 + data-bf-other-inp="' . $rowID . '-chk-' . $optCount . '"
140 145 type="text"
141 - class="{$fieldHelpers->getConversationalCls('other-inp')} {$fieldHelpers->getCustomClasses('other-inp')}"
142 - {$inpReq}
143 - {$inputPh}
146 + class="' . $fieldHelpers->getConversationalCls('other-inp') . ' ' . $fieldHelpers->getCustomClasses('other-inp') . '"
147 + ' . $inpReq . '
148 + ' . $inputPh . '
144 149 />
145 150 </div>
146 151 </div>
147 -CHECKBOXOPTIONS;
152 +';
148 153 }
149 154
150 - return <<<CHECKBOXFIELD
151 -<div
152 - {$fieldHelpers->getCustomAttributes('cc')}
153 - class="{$fieldHelpers->getConversationalCls('cc')} {$fieldHelpers->getCustomClasses('cc')}"
154 ->
155 - <svg class="{$fieldHelpers->getConversationalCls('cks')}">
156 - <symbol id="{$rowID}-ck-svg" viewBox="0 0 12 10">
157 - <polyline
158 - class="{$fieldHelpers->getConversationalCls('ck-svgline')}"
159 - points="1.5 6 4.5 9 10.5 1"
160 - ></polygon>
161 - </symbol>
162 - </svg>
163 - {$checkBoxOptions}
164 -</div>
165 -CHECKBOXFIELD;
155 + return sprintf(
156 + '<div' . "\n"
157 + . ' %1$s' . "\n"
158 + . ' class="%2$s %3$s"' . "\n"
159 + . ' role="group" ' . "\n"
160 + . ' aria-labelledby="%4$s" ' . "\n"
161 + . ' %5$s ' . "\n"
162 + . '>' . "\n"
163 + . ' <svg class="%6$s" aria-hidden="true">' . "\n"
164 + . ' <symbol id="%7$s-ck-svg" viewBox="0 0 12 10">' . "\n"
165 + . ' <polyline' . "\n"
166 + . ' class="%8$s"' . "\n"
167 + . ' points="1.5 6 4.5 9 10.5 1"' . "\n"
168 + . ' ></polyline>' . "\n"
169 + . ' </symbol>' . "\n"
170 + . ' </svg>' . "\n"
171 + . ' %9$s' . "\n"
172 + . '</div>',
173 + $fieldHelpers->getCustomAttributes('cc'),
174 + $fieldHelpers->getConversationalCls('cc'),
175 + $fieldHelpers->getCustomClasses('cc'),
176 + $labelId,
177 + $ariaDescribedBy,
178 + $fieldHelpers->getConversationalCls('cks'),
179 + $rowID,
180 + $fieldHelpers->getConversationalCls('ck-svgline'),
181 + $checkBoxOptions
182 + );
166 183 }
167 184 }