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 +8 -45 6.265.2.06 View file →
@@ -4,11 +4,8 @@
4 4 }
5 5
6 6 class FrmFieldGridHelper {
7 7
8 - /**
9 - * @var bool|string
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,9 +140,8 @@
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 147 return ! $this->can_support_current_layout() || $this->is_frm_first;
@@ -164,11 +146,8 @@
164 146 }
165 147 return ! $this->can_support_current_layout() || $this->is_frm_first;
166 148 }
167 149
168 - /**
169 - * @return void
170 - */
171 150 private function begin_field_wrapper() {
172 151 echo '<li class="frm_field_box"><ul class="frm_grid_container frm_sorting">';
173 152 $this->parent_li = true;
174 153 $this->current_list_size = 0;
@@ -176,9 +155,8 @@
176 155 }
177 156
178 157 /**
179 158 * @param string $class
180 - *
181 159 * @return int
182 160 */
183 161 private static function get_size_of_class( $class ) {
184 162 switch ( $class ) {
@@ -197,9 +175,8 @@
197 175 }
198 176
199 177 if ( 0 === strpos( $class, 'frm' ) ) {
200 178 $substr = substr( $class, 3 );
201 -
202 179 if ( is_numeric( $substr ) ) {
203 180 return (int) $substr;
204 181 }
205 182 }
@@ -207,13 +184,10 @@
207 184 // Anything missing a layout class should be a full width row.
208 185 return 12;
209 186 }
210 187
211 - /**
212 - * @return void
213 - */
214 188 public function sync_list_size() {
215 - if ( empty( $this->field ) ) {
189 + if ( ! isset( $this->field ) ) {
216 190 return;
217 191 }
218 192
219 193 if ( 'divider' === $this->field->type ) {
@@ -221,9 +195,8 @@
221 195 }
222 196
223 197 if ( ! empty( $this->section_helper ) ) {
224 198 $this->section_helper->sync_list_size();
225 -
226 199 if ( 'end_divider' === $this->field->type ) {
227 200 $this->maybe_close_section_helper();
228 201 }
229 202 return;
@@ -229,11 +202,10 @@
229 202 return;
230 203 }
231 204
232 205 if ( false !== $this->parent_li ) {
233 - ++$this->current_field_count;
206 + $this->current_field_count ++;
234 207 $this->current_list_size += $this->active_field_size;
235 -
236 208 if ( 12 === $this->current_list_size ) {
237 209 $this->close_field_wrapper();
238 210 }
239 211 }
@@ -241,10 +213,8 @@
241 213
242 214 /**
243 215 * It is possible that there was still space for another field so the wrapper could still be open after looping the fields.
244 216 * If it is, make sure it's closed now.
245 - *
246 - * @return void
247 217 */
248 218 public function force_close_field_wrapper() {
249 219 if ( false !== $this->parent_li ) {
250 220 $this->close_field_wrapper();
@@ -250,11 +220,8 @@
250 220 $this->close_field_wrapper();
251 221 }
252 222 }
253 223
254 - /**
255 - * @return void
256 - */
257 224 private function close_field_wrapper() {
258 225 $this->maybe_close_section_helper();
259 226 echo '</ul></li>';
260 227 $this->parent_li = false;
@@ -261,11 +228,8 @@
261 228 $this->current_list_size = 0;
262 229 $this->current_field_count = 0;
263 230 }
264 231
265 - /**
266 - * @return bool
267 - */
268 232 private function can_support_current_layout() {
269 233 if ( 'end_divider' === $this->field->type ) {
270 234 return true;
271 235 }
@@ -273,13 +237,12 @@
273 237 }
274 238
275 239 /**
276 240 * @param string $class
277 - *
278 241 * @return bool
279 242 */
280 243 private function can_support_an_additional_layout( $class ) {
281 - $size = self::get_size_of_class( $class );
244 + $size = $this->get_size_of_class( $class );
282 245 return $this->current_list_size + $size <= 12;
283 246 }
284 247
285 248 /**