PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.21
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.21
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmFieldGridHelper.php +19 -40 6.296.21 View file →
@@ -4,11 +4,8 @@
4 4 }
5 5
6 6 class FrmFieldGridHelper {
7 7
8 - /**
9 - * @var bool
10 - */
11 8 private $parent_li;
12 9
13 10 /**
14 11 * @var int
@@ -35,14 +32,14 @@
35 32 */
36 33 private $is_frm_first;
37 34
38 35 /**
39 - * @var stdClass|null
36 + * @var stdClass
40 37 */
41 38 private $field;
42 39
43 40 /**
44 - * @var FrmFieldGridHelper|null
41 + * @var FrmFieldGridHelper
45 42 */
46 43 private $section_helper;
47 44
48 45 /**
@@ -54,16 +51,10 @@
54 51 * @var int
55 52 */
56 53 private $section_size;
57 54
58 - /**
59 - * @var bool
60 - */
61 55 private $section_is_open = false;
62 56
63 - /**
64 - * @param bool $nested
65 - */
66 57 public function __construct( $nested = false ) {
67 58 $this->parent_li = false;
68 59 $this->current_list_size = 0;
69 60 $this->current_field_count = 0;
@@ -77,9 +68,9 @@
77 68 */
78 69 public function set_field( $field ) {
79 70 $this->field = $field;
80 71
81 - if ( $this->section_helper && 'end_divider' !== $field->type ) {
72 + if ( ! empty( $this->section_helper ) && 'end_divider' !== $field->type ) {
82 73 $this->section_helper->set_field( $field );
83 74 return;
84 75 }
85 76
@@ -92,15 +83,13 @@
92 83 $this->field_layout_class = $this->get_field_layout_class();
93 84 $this->active_field_size = self::get_size_of_class( $this->field_layout_class );
94 85 }
95 86
96 - if ( 'divider' !== $field->type || $this->nested ) {
97 - return;
87 + if ( 'divider' === $field->type && empty( $this->nested ) ) {
88 + $this->section_size = $this->active_field_size;
89 + $this->active_field_size = 0;
90 + $this->section_helper = new self( true );
98 91 }
99 -
100 - $this->section_size = $this->active_field_size;
101 - $this->active_field_size = 0;
102 - $this->section_helper = new self( true );
103 92 }
104 93
105 94 /**
106 95 * @return void
@@ -105,9 +94,9 @@
105 94 /**
106 95 * @return void
107 96 */
108 97 private function maybe_close_section_helper() {
109 - if ( ! $this->section_helper ) {
98 + if ( empty( $this->section_helper ) ) {
110 99 return;
111 100 }
112 101 $this->section_helper->force_close_field_wrapper();
113 102 $this->section_helper = null;
@@ -147,9 +136,9 @@
147 136 if ( false === $this->parent_li && 'end_divider' !== $this->field->type ) {
148 137 $this->begin_field_wrapper();
149 138 }
150 139
151 - if ( $this->section_helper && $this->section_is_open ) {
140 + if ( ! empty( $this->section_helper ) && $this->section_is_open ) {
152 141 $this->section_helper->maybe_begin_field_wrapper();
153 142 }
154 143 }
155 144
@@ -156,16 +145,14 @@
156 145 /**
157 146 * @return bool
158 147 */
159 148 private function should_first_close_the_active_field_wrapper() {
160 - if ( false === $this->parent_li || $this->section_helper ) {
149 + if ( false === $this->parent_li || ! empty( $this->section_helper ) ) {
161 150 return false;
162 151 }
163 -
164 152 if ( 'end_divider' === $this->field->type ) {
165 153 return false;
166 154 }
167 -
168 155 return ! $this->can_support_current_layout() || $this->is_frm_first;
169 156 }
170 157
171 158 /**
@@ -179,9 +166,8 @@
179 166 }
180 167
181 168 /**
182 169 * @param string $class
183 - *
184 170 * @return int
185 171 */
186 172 private static function get_size_of_class( $class ) {
187 173 switch ( $class ) {
@@ -198,11 +184,10 @@
198 184 case 'frm_sixth':
199 185 return 2;
200 186 }
201 187
202 - if ( str_starts_with( $class, 'frm' ) ) {
188 + if ( 0 === strpos( $class, 'frm' ) ) {
203 189 $substr = substr( $class, 3 );
204 -
205 190 if ( is_numeric( $substr ) ) {
206 191 return (int) $substr;
207 192 }
208 193 }
@@ -214,9 +199,9 @@
214 199 /**
215 200 * @return void
216 201 */
217 202 public function sync_list_size() {
218 - if ( ! $this->field ) {
203 + if ( empty( $this->field ) ) {
219 204 return;
220 205 }
221 206
222 207 if ( 'divider' === $this->field->type ) {
@@ -222,28 +207,23 @@
222 207 if ( 'divider' === $this->field->type ) {
223 208 $this->section_is_open = true;
224 209 }
225 210
226 - if ( $this->section_helper ) {
211 + if ( ! empty( $this->section_helper ) ) {
227 212 $this->section_helper->sync_list_size();
228 -
229 213 if ( 'end_divider' === $this->field->type ) {
230 214 $this->maybe_close_section_helper();
231 215 }
232 -
233 216 return;
234 217 }
235 218
236 - if ( false === $this->parent_li ) {
237 - return;
219 + if ( false !== $this->parent_li ) {
220 + ++$this->current_field_count;
221 + $this->current_list_size += $this->active_field_size;
222 + if ( 12 === $this->current_list_size ) {
223 + $this->close_field_wrapper();
224 + }
238 225 }
239 -
240 - ++$this->current_field_count;
241 - $this->current_list_size += $this->active_field_size;
242 -
243 - if ( 12 === $this->current_list_size ) {
244 - $this->close_field_wrapper();
245 - }
246 226 }
247 227
248 228 /**
249 229 * It is possible that there was still space for another field so the wrapper could still be open after looping the fields.
@@ -279,9 +259,8 @@
279 259 }
280 260
281 261 /**
282 262 * @param string $class
283 - *
284 263 * @return bool
285 264 */
286 265 private function can_support_an_additional_layout( $class ) {
287 266 $size = self::get_size_of_class( $class );