PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.4.5
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.4.5
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 +16 -98 6.255.4.5 View file →
@@ -53,26 +53,8 @@
53 53 */
54 54 protected $td_style = '';
55 55
56 56 /**
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 57 * Used to add a class in tables. Set in Pro.
76 58 *
77 59 * @var bool
78 60 * @since 5.4.2
@@ -82,22 +64,13 @@
82 64 /**
83 65 * FrmTableHTMLGenerator constructor.
84 66 *
85 67 * @param string $type
86 - * @param array $atts
68 + * @param array $atts
87 69 */
88 70 public function __construct( $type, $atts = array() ) {
89 71
90 72 $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 73 $this->init_style_settings( $atts );
101 74 $this->init_use_inline_style( $atts );
102 75 $this->init_direction( $atts );
103 76 $this->init_table_style();
@@ -109,9 +82,8 @@
109 82 *
110 83 * @since 2.04
111 84 *
112 85 * @param array $atts
113 - * @return void
114 86 */
115 87 private function init_style_settings( $atts ) {
116 88 $style_settings = array(
117 89 'border_color' => 'dddddd',
@@ -132,9 +104,9 @@
132 104 $this->style_settings[ $key ] = $this->get_color_markup( $this->style_settings[ $key ] );
133 105 }
134 106 }
135 107
136 - $this->style_settings['class'] = $atts['class'] ?? '';
108 + $this->style_settings['class'] = isset( $atts['class'] ) ? $atts['class'] : '';
137 109 }
138 110
139 111 /**
140 112 * Set the use_inline_style property
@@ -141,9 +113,8 @@
141 113 *
142 114 * @since 2.04
143 115 *
144 116 * @param array $atts
145 - * @return void
146 117 */
147 118 private function init_use_inline_style( $atts ) {
148 119 if ( isset( $atts['inline_style'] ) && ! $atts['inline_style'] ) {
149 120 $this->use_inline_style = false;
@@ -155,9 +126,8 @@
155 126 *
156 127 * @since 2.04
157 128 *
158 129 * @param array $atts
159 - * @return void
160 130 */
161 131 private function init_direction( $atts ) {
162 132 if ( isset( $atts['direction'] ) && $atts['direction'] === 'rtl' ) {
163 133 $this->direction = 'rtl';
@@ -167,14 +137,13 @@
167 137 /**
168 138 * Set the table_style property
169 139 *
170 140 * @since 2.04
171 - * @return void
172 141 */
173 142 private function init_table_style() {
174 143 if ( $this->use_inline_style === true ) {
175 144
176 - $this->table_style = ' style="' . esc_attr( 'border-spacing:0;font-size:' . $this->style_settings['font_size'] . ';line-height:135%;' );
145 + $this->table_style = ' style="' . esc_attr( 'font-size:' . $this->style_settings['font_size'] . ';line-height:135%;' );
177 146 $this->table_style .= esc_attr( 'border-bottom:' . $this->style_settings['border_width'] . ' solid ' . $this->style_settings['border_color'] . ';' ) . '"';
178 147
179 148 }
180 149
@@ -180,12 +149,8 @@
180 149
181 150 if ( ! empty( $this->style_settings['class'] ) ) {
182 151 $this->table_style .= ' class="' . esc_attr( $this->style_settings['class'] ) . '"';
183 152 }
184 -
185 - if ( ! empty( $this->width ) ) {
186 - $this->table_style .= ' width="' . esc_attr( $this->width ) . '"';
187 - }
188 153 }
189 154
190 155 /**
191 156 * Set the td_style property
@@ -190,48 +155,28 @@
190 155 /**
191 156 * Set the td_style property
192 157 *
193 158 * @since 2.04
194 - * @return void
195 159 */
196 160 private function init_td_style() {
197 161 if ( $this->use_inline_style === true ) {
198 162
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;';
163 + $td_style_attributes = 'text-align:' . ( $this->direction == 'rtl' ? 'right' : 'left' ) . ';';
164 + $td_style_attributes .= 'color:' . $this->style_settings['text_color'] . ';padding:7px 9px;vertical-align:top;';
201 165 $td_style_attributes .= 'border-top:' . $this->style_settings['border_width'] . ' solid ' . $this->style_settings['border_color'] . ';';
202 166
203 - $this->td_style = ' style="' . esc_attr( $td_style_attributes ) . '"';
167 + $this->td_style = ' style="' . $td_style_attributes . '"';
204 168 }
205 169 }
206 170
207 171 /**
208 - * Removes border CSS from HTML.
172 + * Determine if setting is for a color, e.g. text color, background color, or border color
209 173 *
210 - * @since 6.25
174 + * @param string $setting_key name of setting
211 175 *
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 176 * @since 2.05
231 - * @param string $setting_key Name of setting.
232 177 *
233 - * @return bool
178 + * @return boolean
234 179 */
235 180 private function is_color_setting( $setting_key ) {
236 181 return strpos( $setting_key, 'color' ) !== false;
237 182 }
@@ -238,10 +183,11 @@
238 183
239 184 /**
240 185 * Get color markup from color setting value
241 186 *
187 + * @param string $color_markup value of a color setting, with format #FFFFF, FFFFFF, or white.
188 + *
242 189 * @since 2.05
243 - * @param string $color_markup value of a color setting, with format #FFFFF, FFFFFF, or white.
244 190 *
245 191 * @return string
246 192 */
247 193 private function get_color_markup( $color_markup ) {
@@ -270,13 +216,12 @@
270 216 * Get the table row style
271 217 *
272 218 * @since 2.04
273 219 * @since 5.0.16 Changed scope from `private` to `protected`.
274 - * @since 6.25 Changed scope from `protected` to `public`.
275 220 *
276 221 * @return string
277 222 */
278 - public function tr_style() {
223 + protected function tr_style() {
279 224
280 225 if ( $this->type === 'shortcode' ) {
281 226 $tr_style = ' style="[frm-alt-color]"';
282 227 } elseif ( $this->use_inline_style ) {
@@ -288,36 +233,12 @@
288 233 return $tr_style;
289 234 }
290 235
291 236 /**
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 237 * Switch the odd property from true to false or false to true
315 238 *
316 239 * @since 2.04
317 240 * @since 5.0.16 Changed scope from `private` to `protected`.
318 - *
319 - * @return void
320 241 */
321 242 protected function switch_odd() {
322 243 if ( $this->type !== 'shortcode' ) {
323 244 $this->odd = ! $this->odd;
@@ -331,9 +252,9 @@
331 252 *
332 253 * @return string
333 254 */
334 255 public function generate_table_header() {
335 - return '<table cellspacing="0"' . $this->table_style . '><tbody>' . "\r\n";
256 + return '<table cellspacing="0" ' . $this->table_style . '><tbody>' . "\r\n";
336 257 }
337 258
338 259 /**
339 260 * Generate a table footer
@@ -356,13 +277,13 @@
356 277 *
357 278 * @return string
358 279 */
359 280 public function generate_two_cell_table_row( $label, $value ) {
360 - $row = '<tr' . $this->tr_style();
281 + $row = '<tr' . $this->tr_style();
361 282 $row .= $this->add_row_class( $value === '' );
362 283 $row .= '>';
363 284
364 - $label = '<th scope="row"' . $this->td_style . '>' . wp_kses_post( $label ) . '</th>';
285 + $label = '<th' . $this->td_style . '>' . wp_kses_post( $label ) . '</th>';
365 286 $value = '<td' . $this->td_style . '>' . wp_kses_post( $value ) . '</td>';
366 287
367 288 if ( 'rtl' == $this->direction ) {
368 289 $row .= $value;
@@ -388,9 +309,9 @@
388 309 *
389 310 * @return string
390 311 */
391 312 public function generate_single_cell_table_row( $value ) {
392 - $row = '<tr' . $this->tr_style();
313 + $row = '<tr' . $this->tr_style();
393 314 $row .= $this->add_row_class();
394 315 $row .= '>';
395 316 $row .= '<td colspan="2"' . $this->td_style . '>' . $value . '</td>';
396 317 $row .= '</tr>' . "\r\n";
@@ -403,12 +324,9 @@
403 324 /**
404 325 * Add classes to the tr.
405 326 *
406 327 * @since 5.4.2
407 - *
408 328 * @param bool $empty If the value in the row is blank.
409 - *
410 - * @return string
411 329 */
412 330 protected function add_row_class( $empty = false ) {
413 331 $class = '';
414 332 if ( $empty ) {