PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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/models/FrmTableHTMLGenerator.php +27 -143 6.255.0 View file →
@@ -28,11 +28,10 @@
28 28
29 29 /**
30 30 * @var string
31 31 * @since 2.04
32 - * @since 5.0.16 Changed scope from `private` to `protected`.
33 32 */
34 - protected $direction = 'ltr';
33 + private $direction = 'ltr';
35 34
36 35 /**
37 36 * @var bool
38 37 * @since 2.04
@@ -41,63 +40,26 @@
41 40
42 41 /**
43 42 * @var string
44 43 * @since 2.04
45 - * @since 5.0.16 Changed scope from `private` to `protected`.
46 44 */
47 - protected $table_style = '';
45 + private $table_style = '';
48 46
49 47 /**
50 48 * @var string
51 49 * @since 2.04
52 - * @since 5.0.16 Changed scope from `private` to `protected`.
53 50 */
54 - protected $td_style = '';
51 + private $td_style = '';
55 52
56 53 /**
57 - * Cell padding.
58 - *
59 - * @since 6.25
60 - *
61 - * @var string
62 - */
63 - protected $cell_padding = '7px 9px';
64 -
65 - /**
66 - * Table width.
67 - *
68 - * @since 6.25
69 - *
70 - * @var string
71 - */
72 - protected $width = '';
73 -
74 - /**
75 - * Used to add a class in tables. Set in Pro.
76 - *
77 - * @var bool
78 - * @since 5.4.2
79 - */
80 - public $is_child = false;
81 -
82 - /**
83 54 * FrmTableHTMLGenerator constructor.
84 55 *
85 56 * @param string $type
86 - * @param array $atts
57 + * @param array $atts
87 58 */
88 59 public function __construct( $type, $atts = array() ) {
89 60
90 61 $this->type = (string) $type;
91 -
92 - if ( isset( $atts['cell_padding'] ) ) {
93 - $this->cell_padding = $atts['cell_padding'];
94 - }
95 -
96 - if ( isset( $atts['width'] ) ) {
97 - $this->width = $atts['width'];
98 - }
99 -
100 62 $this->init_style_settings( $atts );
101 63 $this->init_use_inline_style( $atts );
102 64 $this->init_direction( $atts );
103 65 $this->init_table_style();
@@ -109,9 +71,8 @@
109 71 *
110 72 * @since 2.04
111 73 *
112 74 * @param array $atts
113 - * @return void
114 75 */
115 76 private function init_style_settings( $atts ) {
116 77 $style_settings = array(
117 78 'border_color' => 'dddddd',
@@ -132,9 +93,9 @@
132 93 $this->style_settings[ $key ] = $this->get_color_markup( $this->style_settings[ $key ] );
133 94 }
134 95 }
135 96
136 - $this->style_settings['class'] = $atts['class'] ?? '';
97 + $this->style_settings['class'] = isset( $atts['class'] ) ? $atts['class'] : '';
137 98 }
138 99
139 100 /**
140 101 * Set the use_inline_style property
@@ -141,9 +102,8 @@
141 102 *
142 103 * @since 2.04
143 104 *
144 105 * @param array $atts
145 - * @return void
146 106 */
147 107 private function init_use_inline_style( $atts ) {
148 108 if ( isset( $atts['inline_style'] ) && ! $atts['inline_style'] ) {
149 109 $this->use_inline_style = false;
@@ -155,9 +115,8 @@
155 115 *
156 116 * @since 2.04
157 117 *
158 118 * @param array $atts
159 - * @return void
160 119 */
161 120 private function init_direction( $atts ) {
162 121 if ( isset( $atts['direction'] ) && $atts['direction'] === 'rtl' ) {
163 122 $this->direction = 'rtl';
@@ -167,14 +126,13 @@
167 126 /**
168 127 * Set the table_style property
169 128 *
170 129 * @since 2.04
171 - * @return void
172 130 */
173 131 private function init_table_style() {
174 132 if ( $this->use_inline_style === true ) {
175 133
176 - $this->table_style = ' style="' . esc_attr( 'border-spacing:0;font-size:' . $this->style_settings['font_size'] . ';line-height:135%;' );
134 + $this->table_style = ' style="' . esc_attr( 'font-size:' . $this->style_settings['font_size'] . ';line-height:135%;' );
177 135 $this->table_style .= esc_attr( 'border-bottom:' . $this->style_settings['border_width'] . ' solid ' . $this->style_settings['border_color'] . ';' ) . '"';
178 136
179 137 }
180 138
@@ -180,12 +138,8 @@
180 138
181 139 if ( ! empty( $this->style_settings['class'] ) ) {
182 140 $this->table_style .= ' class="' . esc_attr( $this->style_settings['class'] ) . '"';
183 141 }
184 -
185 - if ( ! empty( $this->width ) ) {
186 - $this->table_style .= ' width="' . esc_attr( $this->width ) . '"';
187 - }
188 142 }
189 143
190 144 /**
191 145 * Set the td_style property
@@ -190,48 +144,28 @@
190 144 /**
191 145 * Set the td_style property
192 146 *
193 147 * @since 2.04
194 - * @return void
195 148 */
196 149 private function init_td_style() {
197 150 if ( $this->use_inline_style === true ) {
198 151
199 - $td_style_attributes = 'text-align:' . ( $this->direction === 'rtl' ? 'right' : 'left' ) . ';';
200 - $td_style_attributes .= 'color:' . $this->style_settings['text_color'] . ';padding:' . $this->cell_padding . ';vertical-align:top;';
152 + $td_style_attributes = 'text-align:' . ( $this->direction == 'rtl' ? 'right' : 'left' ) . ';';
153 + $td_style_attributes .= 'color:' . $this->style_settings['text_color'] . ';padding:7px 9px;vertical-align:top;';
201 154 $td_style_attributes .= 'border-top:' . $this->style_settings['border_width'] . ' solid ' . $this->style_settings['border_color'] . ';';
202 155
203 - $this->td_style = ' style="' . esc_attr( $td_style_attributes ) . '"';
156 + $this->td_style = ' style="' . $td_style_attributes . '"';
204 157 }
205 158 }
206 159
207 160 /**
208 - * Removes border CSS from HTML.
161 + * Determine if setting is for a color, e.g. text color, background color, or border color
209 162 *
210 - * @since 6.25
163 + * @param string $setting_key name of setting
211 164 *
212 - * @param string $html The HTML.
213 - * @param string $position The border position. Default is `top`.
214 - * @return string
215 - */
216 - public function remove_border( $html, $position = 'top' ) {
217 - $search = sprintf(
218 - 'border-%1$s:%2$s solid %3$s;',
219 - $position,
220 - $this->style_settings['border_width'],
221 - $this->style_settings['border_color']
222 - );
223 -
224 - return str_replace( $search, '', $html );
225 - }
226 -
227 - /**
228 - * Determine if setting is for a color, e.g. text color, background color, or border color
229 - *
230 165 * @since 2.05
231 - * @param string $setting_key Name of setting.
232 166 *
233 - * @return bool
167 + * @return boolean
234 168 */
235 169 private function is_color_setting( $setting_key ) {
236 170 return strpos( $setting_key, 'color' ) !== false;
237 171 }
@@ -238,10 +172,11 @@
238 172
239 173 /**
240 174 * Get color markup from color setting value
241 175 *
176 + * @param string $color_markup value of a color setting, with format #FFFFF, FFFFFF, or white.
177 + *
242 178 * @since 2.05
243 - * @param string $color_markup value of a color setting, with format #FFFFF, FFFFFF, or white.
244 179 *
245 180 * @return string
246 181 */
247 182 private function get_color_markup( $color_markup ) {
@@ -246,10 +181,10 @@
246 181 */
247 182 private function get_color_markup( $color_markup ) {
248 183 $color_markup = trim( $color_markup );
249 184
250 - // Check if each character in string is valid hex digit
251 - if ( FrmAppHelper::ctype_xdigit( $color_markup ) ) {
185 + //check if each character in string is valid hex digit
186 + if ( ctype_xdigit( $color_markup ) ) {
252 187 $color_markup = '#' . $color_markup;
253 188 }
254 189
255 190 return $color_markup;
@@ -269,14 +204,12 @@
269 204 /**
270 205 * Get the table row style
271 206 *
272 207 * @since 2.04
273 - * @since 5.0.16 Changed scope from `private` to `protected`.
274 - * @since 6.25 Changed scope from `protected` to `public`.
275 208 *
276 209 * @return string
277 210 */
278 - public function tr_style() {
211 + private function tr_style() {
279 212
280 213 if ( $this->type === 'shortcode' ) {
281 214 $tr_style = ' style="[frm-alt-color]"';
282 215 } elseif ( $this->use_inline_style ) {
@@ -288,38 +221,13 @@
288 221 return $tr_style;
289 222 }
290 223
291 224 /**
292 - * Gets table style.
293 - *
294 - * @since 6.25
295 - *
296 - * @return string
297 - */
298 - public function get_table_style() {
299 - return $this->table_style;
300 - }
301 -
302 - /**
303 - * Gets td style.
304 - *
305 - * @since 6.25
306 - *
307 - * @return string
308 - */
309 - public function get_td_style() {
310 - return $this->td_style;
311 - }
312 -
313 - /**
314 225 * Switch the odd property from true to false or false to true
315 226 *
316 227 * @since 2.04
317 - * @since 5.0.16 Changed scope from `private` to `protected`.
318 - *
319 - * @return void
320 228 */
321 - protected function switch_odd() {
229 + private function switch_odd() {
322 230 if ( $this->type !== 'shortcode' ) {
323 231 $this->odd = ! $this->odd;
324 232 }
325 233 }
@@ -331,9 +239,9 @@
331 239 *
332 240 * @return string
333 241 */
334 242 public function generate_table_header() {
335 - return '<table cellspacing="0"' . $this->table_style . '><tbody>' . "\r\n";
243 + return '<table cellspacing="0" ' . $this->table_style . '><tbody>' . "\r\n";
336 244 }
337 245
338 246 /**
339 247 * Generate a table footer
@@ -350,19 +258,21 @@
350 258 * Generate a two cell row for an HTML table
351 259 *
352 260 * @since 2.04
353 261 *
354 - * @param string $label The label.
355 - * @param string $value The value.
262 + * @param string $label
263 + * @param string $value
356 264 *
357 265 * @return string
358 266 */
359 267 public function generate_two_cell_table_row( $label, $value ) {
360 - $row = '<tr' . $this->tr_style();
361 - $row .= $this->add_row_class( $value === '' );
268 + $row = '<tr' . $this->tr_style();
269 + if ( $value === '' ) {
270 + $row .= ' class="frm-empty-row"';
271 + }
362 272 $row .= '>';
363 273
364 - $label = '<th scope="row"' . $this->td_style . '>' . wp_kses_post( $label ) . '</th>';
274 + $label = '<th' . $this->td_style . '>' . wp_kses_post( $label ) . '</th>';
365 275 $value = '<td' . $this->td_style . '>' . wp_kses_post( $value ) . '</td>';
366 276
367 277 if ( 'rtl' == $this->direction ) {
368 278 $row .= $value;
@@ -388,11 +298,9 @@
388 298 *
389 299 * @return string
390 300 */
391 301 public function generate_single_cell_table_row( $value ) {
392 - $row = '<tr' . $this->tr_style();
393 - $row .= $this->add_row_class();
394 - $row .= '>';
302 + $row = '<tr' . $this->tr_style() . '>';
395 303 $row .= '<td colspan="2"' . $this->td_style . '>' . $value . '</td>';
396 304 $row .= '</tr>' . "\r\n";
397 305
398 306 $this->switch_odd();
@@ -397,30 +305,6 @@
397 305
398 306 $this->switch_odd();
399 307
400 308 return $row;
401 - }
402 -
403 - /**
404 - * Add classes to the tr.
405 - *
406 - * @since 5.4.2
407 - *
408 - * @param bool $empty If the value in the row is blank.
409 - *
410 - * @return string
411 - */
412 - protected function add_row_class( $empty = false ) {
413 - $class = '';
414 - if ( $empty ) {
415 - // Only add this class on two cell rows.
416 - $class .= ' frm-empty-row';
417 - }
418 - if ( $this->is_child ) {
419 - $class .= ' frm-child-row';
420 - }
421 - if ( $class ) {
422 - $class = ' class="' . trim( $class ) . '"';
423 - }
424 - return $class;
425 309 }
426 310 }