PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.2.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.2.06
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 +9 -48 6.275.2.06 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
@@ -30,9 +27,9 @@
30 27 */
31 28 private $active_field_size;
32 29
33 30 /**
34 - * @var bool flagged while calling get_field_layout_class, true if classes contain frm_first class.
31 + * @var bool $is_frm_first flagged while calling get_field_layout_class, true if classes contain frm_first class.
35 32 */
36 33 private $is_frm_first;
37 34
38 35 /**
@@ -40,30 +37,24 @@
40 37 */
41 38 private $field;
42 39
43 40 /**
44 - * @var FrmFieldGridHelper
41 + * @var FrmFieldGridHelper $section_helper
45 42 */
46 43 private $section_helper;
47 44
48 45 /**
49 - * @var bool
46 + * @var bool $nested
50 47 */
51 48 private $nested;
52 49
53 50 /**
54 - * @var int
51 + * @var int $section_size
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;
@@ -71,10 +62,8 @@
71 62 }
72 63
73 64 /**
74 65 * @param stdClass $field
75 - *
76 - * @return void
77 66 */
78 67 public function set_field( $field ) {
79 68 $this->field = $field;
80 69
@@ -89,9 +78,9 @@
89 78 $this->section_is_open = false;
90 79 $this->maybe_close_section_helper();
91 80 } else {
92 81 $this->field_layout_class = $this->get_field_layout_class();
93 - $this->active_field_size = self::get_size_of_class( $this->field_layout_class );
82 + $this->active_field_size = $this->get_size_of_class( $this->field_layout_class );
94 83 }
95 84
96 85 if ( 'divider' === $field->type && empty( $this->nested ) ) {
97 86 $this->section_size = $this->active_field_size;
@@ -99,11 +88,8 @@
99 88 $this->section_helper = new self( true );
100 89 }
101 90 }
102 91
103 - /**
104 - * @return void
105 - */
106 92 private function maybe_close_section_helper() {
107 93 if ( empty( $this->section_helper ) ) {
108 94 return;
109 95 }
@@ -133,11 +119,8 @@
133 119
134 120 return '';
135 121 }
136 122
137 - /**
138 - * @return void
139 - */
140 123 public function maybe_begin_field_wrapper() {
141 124 if ( $this->should_first_close_the_active_field_wrapper() ) {
142 125 $this->close_field_wrapper();
143 126 }
@@ -157,19 +140,14 @@
157 140 private function should_first_close_the_active_field_wrapper() {
158 141 if ( false === $this->parent_li || ! empty( $this->section_helper ) ) {
159 142 return false;
160 143 }
161 -
162 144 if ( 'end_divider' === $this->field->type ) {
163 145 return false;
164 146 }
165 -
166 147 return ! $this->can_support_current_layout() || $this->is_frm_first;
167 148 }
168 149
169 - /**
170 - * @return void
171 - */
172 150 private function begin_field_wrapper() {
173 151 echo '<li class="frm_field_box"><ul class="frm_grid_container frm_sorting">';
174 152 $this->parent_li = true;
175 153 $this->current_list_size = 0;
@@ -177,9 +155,8 @@
177 155 }
178 156
179 157 /**
180 158 * @param string $class
181 - *
182 159 * @return int
183 160 */
184 161 private static function get_size_of_class( $class ) {
185 162 switch ( $class ) {
@@ -196,11 +173,10 @@
196 173 case 'frm_sixth':
197 174 return 2;
198 175 }
199 176
200 - if ( str_starts_with( $class, 'frm' ) ) {
177 + if ( 0 === strpos( $class, 'frm' ) ) {
201 178 $substr = substr( $class, 3 );
202 -
203 179 if ( is_numeric( $substr ) ) {
204 180 return (int) $substr;
205 181 }
206 182 }
@@ -208,13 +184,10 @@
208 184 // Anything missing a layout class should be a full width row.
209 185 return 12;
210 186 }
211 187
212 - /**
213 - * @return void
214 - */
215 188 public function sync_list_size() {
216 - if ( empty( $this->field ) ) {
189 + if ( ! isset( $this->field ) ) {
217 190 return;
218 191 }
219 192
220 193 if ( 'divider' === $this->field->type ) {
@@ -222,20 +195,17 @@
222 195 }
223 196
224 197 if ( ! empty( $this->section_helper ) ) {
225 198 $this->section_helper->sync_list_size();
226 -
227 199 if ( 'end_divider' === $this->field->type ) {
228 200 $this->maybe_close_section_helper();
229 201 }
230 -
231 202 return;
232 203 }
233 204
234 205 if ( false !== $this->parent_li ) {
235 - ++$this->current_field_count;
206 + $this->current_field_count ++;
236 207 $this->current_list_size += $this->active_field_size;
237 -
238 208 if ( 12 === $this->current_list_size ) {
239 209 $this->close_field_wrapper();
240 210 }
241 211 }
@@ -243,10 +213,8 @@
243 213
244 214 /**
245 215 * It is possible that there was still space for another field so the wrapper could still be open after looping the fields.
246 216 * If it is, make sure it's closed now.
247 - *
248 - * @return void
249 217 */
250 218 public function force_close_field_wrapper() {
251 219 if ( false !== $this->parent_li ) {
252 220 $this->close_field_wrapper();
@@ -252,11 +220,8 @@
252 220 $this->close_field_wrapper();
253 221 }
254 222 }
255 223
256 - /**
257 - * @return void
258 - */
259 224 private function close_field_wrapper() {
260 225 $this->maybe_close_section_helper();
261 226 echo '</ul></li>';
262 227 $this->parent_li = false;
@@ -263,11 +228,8 @@
263 228 $this->current_list_size = 0;
264 229 $this->current_field_count = 0;
265 230 }
266 231
267 - /**
268 - * @return bool
269 - */
270 232 private function can_support_current_layout() {
271 233 if ( 'end_divider' === $this->field->type ) {
272 234 return true;
273 235 }
@@ -275,13 +237,12 @@
275 237 }
276 238
277 239 /**
278 240 * @param string $class
279 - *
280 241 * @return bool
281 242 */
282 243 private function can_support_an_additional_layout( $class ) {
283 - $size = self::get_size_of_class( $class );
244 + $size = $this->get_size_of_class( $class );
284 245 return $this->current_list_size + $size <= 12;
285 246 }
286 247
287 248 /**