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 +21 -41 6.306.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;
@@ -124,10 +113,11 @@
124 113 }
125 114
126 115 $split = explode( ' ', $field['classes'] );
127 116 $this->is_frm_first = in_array( 'frm_first', $split, true );
117 + $classes = self::get_grid_classes();
128 118
129 - foreach ( self::get_grid_classes() as $class ) {
119 + foreach ( $classes as $class ) {
130 120 if ( in_array( $class, $split, true ) ) {
131 121 return $class;
132 122 }
133 123 }
@@ -146,9 +136,9 @@
146 136 if ( false === $this->parent_li && 'end_divider' !== $this->field->type ) {
147 137 $this->begin_field_wrapper();
148 138 }
149 139
150 - if ( $this->section_helper && $this->section_is_open ) {
140 + if ( ! empty( $this->section_helper ) && $this->section_is_open ) {
151 141 $this->section_helper->maybe_begin_field_wrapper();
152 142 }
153 143 }
154 144
@@ -155,16 +145,14 @@
155 145 /**
156 146 * @return bool
157 147 */
158 148 private function should_first_close_the_active_field_wrapper() {
159 - if ( false === $this->parent_li || $this->section_helper ) {
149 + if ( false === $this->parent_li || ! empty( $this->section_helper ) ) {
160 150 return false;
161 151 }
162 -
163 152 if ( 'end_divider' === $this->field->type ) {
164 153 return false;
165 154 }
166 -
167 155 return ! $this->can_support_current_layout() || $this->is_frm_first;
168 156 }
169 157
170 158 /**
@@ -178,9 +166,8 @@
178 166 }
179 167
180 168 /**
181 169 * @param string $class
182 - *
183 170 * @return int
184 171 */
185 172 private static function get_size_of_class( $class ) {
186 173 switch ( $class ) {
@@ -197,11 +184,10 @@
197 184 case 'frm_sixth':
198 185 return 2;
199 186 }
200 187
201 - if ( str_starts_with( $class, 'frm' ) ) {
188 + if ( 0 === strpos( $class, 'frm' ) ) {
202 189 $substr = substr( $class, 3 );
203 -
204 190 if ( is_numeric( $substr ) ) {
205 191 return (int) $substr;
206 192 }
207 193 }
@@ -213,9 +199,9 @@
213 199 /**
214 200 * @return void
215 201 */
216 202 public function sync_list_size() {
217 - if ( ! $this->field ) {
203 + if ( empty( $this->field ) ) {
218 204 return;
219 205 }
220 206
221 207 if ( 'divider' === $this->field->type ) {
@@ -221,28 +207,23 @@
221 207 if ( 'divider' === $this->field->type ) {
222 208 $this->section_is_open = true;
223 209 }
224 210
225 - if ( $this->section_helper ) {
211 + if ( ! empty( $this->section_helper ) ) {
226 212 $this->section_helper->sync_list_size();
227 -
228 213 if ( 'end_divider' === $this->field->type ) {
229 214 $this->maybe_close_section_helper();
230 215 }
231 -
232 216 return;
233 217 }
234 218
235 - if ( false === $this->parent_li ) {
236 - 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 + }
237 225 }
238 -
239 - ++$this->current_field_count;
240 - $this->current_list_size += $this->active_field_size;
241 -
242 - if ( 12 === $this->current_list_size ) {
243 - $this->close_field_wrapper();
244 - }
245 226 }
246 227
247 228 /**
248 229 * It is possible that there was still space for another field so the wrapper could still be open after looping the fields.
@@ -278,9 +259,8 @@
278 259 }
279 260
280 261 /**
281 262 * @param string $class
282 - *
283 263 * @return bool
284 264 */
285 265 private function can_support_an_additional_layout( $class ) {
286 266 $size = self::get_size_of_class( $class );