PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
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/FrmFieldFormHtml.php +21 -32 6.256.7 View file →
@@ -5,8 +5,9 @@
5 5
6 6 /**
7 7 * @since 3.0
8 8 */
9 +
9 10 class FrmFieldFormHtml {
10 11
11 12 private $html;
12 13
@@ -40,9 +41,9 @@
40 41 /**
41 42 * @since 3.0
42 43 *
43 44 * @param string $param
44 - * @param array $atts
45 + * @param array $atts
45 46 */
46 47 private function _set( $param, $atts ) {
47 48 if ( isset( $atts[ $param ] ) ) {
48 49 $this->{$param} = $atts[ $param ];
@@ -143,18 +144,18 @@
143 144 /**
144 145 * @since 3.0
145 146 */
146 147 private function replace_field_values() {
147 - // Replace [id].
148 + //replace [id]
148 149 $this->html = str_replace( '[id]', $this->field_id, $this->html );
149 150
150 151 // set the label for
151 152 $this->html = str_replace( 'field_[key]', $this->html_id, $this->html );
152 153
153 - // Replace [key].
154 + //replace [key]
154 155 $this->html = str_replace( '[key]', $this->field_obj->get_field_column( 'field_key' ), $this->html );
155 156
156 - // Replace [field_name].
157 + //replace [field_name]
157 158 $this->html = str_replace( '[field_name]', FrmAppHelper::maybe_kses( $this->field_obj->get_field_column( 'name' ) ), $this->html );
158 159 }
159 160
160 161 /**
@@ -218,9 +219,9 @@
218 219
219 220 if ( is_string( $inner_html[2] ) ) {
220 221 $has_id = strpos( $inner_html[2], ' id=' );
221 222 if ( ! $has_id ) {
222 - $id = 'frm_' . $id . '_' . $this->html_id;
223 + $id = 'frm_' . $id . '_' . $this->html_id;
223 224 $this->html = str_replace( 'class="frm_' . $param, 'id="' . esc_attr( $id ) . '" class="frm_' . esc_attr( $param ), $this->html );
224 225 }
225 226 }
226 227 }
@@ -229,9 +230,9 @@
229 230 * @since 3.0
230 231 */
231 232 private function replace_error_shortcode() {
232 233 $this->maybe_add_error_id();
233 - $error = $this->pass_args['errors'][ 'field' . $this->field_id ] ?? false;
234 + $error = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? $this->pass_args['errors'][ 'field' . $this->field_id ] : false;
234 235
235 236 if ( ! empty( $error ) && false === strpos( $this->html, 'role="alert"' ) && FrmAppHelper::should_include_alert_role_on_field_errors() ) {
236 237 $error_body = self::get_error_body( $this->html );
237 238 if ( is_string( $error_body ) && false === strpos( $error_body, 'role=' ) ) {
@@ -246,9 +247,9 @@
246 247 /**
247 248 * Pull the HTML between [if error] and [/if error] shortcodes.
248 249 *
249 250 * @param string $html
250 - * @return false|string
251 + * @return string|false
251 252 */
252 253 private static function get_error_body( $html ) {
253 254 $start = strpos( $html, '[if error]' );
254 255 if ( false === $start ) {
@@ -294,12 +295,12 @@
294 295 private function replace_form_shortcodes() {
295 296 if ( ! empty( $this->form ) ) {
296 297 $form = (array) $this->form;
297 298
298 - // Replace [form_key].
299 + //replace [form_key]
299 300 $this->html = str_replace( '[form_key]', $form['form_key'], $this->html );
300 301
301 - // Replace [form_name].
302 + //replace [form_name]
302 303 $this->html = str_replace( '[form_name]', $form['name'], $this->html );
303 304 }
304 305 }
305 306
@@ -320,9 +321,9 @@
320 321 */
321 322 private function filter_for_more_shortcodes() {
322 323 $atts = $this->pass_args;
323 324
324 - // If field is not in repeating section.
325 + //If field is not in repeating section
325 326 if ( empty( $atts['section_id'] ) ) {
326 327 $atts = array(
327 328 'errors' => $this->pass_args['errors'],
328 329 'form' => $this->form,
@@ -355,11 +356,11 @@
355 356 $tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
356 357
357 358 $replace_with = '';
358 359
359 - if ( $tag === 'deletelink' && FrmAppHelper::pro_is_installed() ) {
360 + if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
360 361 $replace_with = FrmProEntriesController::entry_delete_link( $shortcode_atts );
361 - } elseif ( $tag === 'input' ) {
362 + } elseif ( $tag == 'input' ) {
362 363 $replace_with = $this->replace_input_shortcode( $shortcode_atts );
363 364 }
364 365
365 366 $this->html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $this->html );
@@ -383,12 +384,12 @@
383 384 * @return array
384 385 */
385 386 private function prepare_input_shortcode_atts( $shortcode_atts ) {
386 387 if ( isset( $shortcode_atts['opt'] ) ) {
387 - --$shortcode_atts['opt'];
388 + $shortcode_atts['opt'] --;
388 389 }
389 390
390 - $field_class = $shortcode_atts['class'] ?? '';
391 + $field_class = isset( $shortcode_atts['class'] ) ? $shortcode_atts['class'] : '';
391 392 $this->field_obj->set_field_column( 'input_class', $field_class );
392 393
393 394 if ( isset( $shortcode_atts['class'] ) ) {
394 395 unset( $shortcode_atts['class'] );
@@ -393,9 +394,9 @@
393 394 if ( isset( $shortcode_atts['class'] ) ) {
394 395 unset( $shortcode_atts['class'] );
395 396 }
396 397
397 - $this->field_obj->set_aria_invalid_error( $shortcode_atts, $this->pass_args );
398 + $shortcode_atts['aria-invalid'] = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? 'true' : 'false';
398 399
399 400 $this->field_obj->set_field_column( 'shortcodes', $shortcode_atts );
400 401
401 402 return $shortcode_atts;
@@ -429,15 +430,13 @@
429 430 */
430 431 private function add_field_div_classes() {
431 432 $classes = $this->get_field_div_classes();
432 433
433 - if ( in_array( $this->field_obj->get_field_column( 'type' ), array( 'html', 'summary' ), true ) && strpos( $this->html, '[error_class]' ) === false ) {
434 + if ( $this->field_obj->get_field_column( 'type' ) == 'html' && strpos( $this->html, '[error_class]' ) === false ) {
434 435 // there is no error_class shortcode for HTML fields
435 - $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . esc_attr( $classes ), $this->html );
436 - return;
436 + $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $classes, $this->html );
437 437 }
438 -
439 - $this->html = str_replace( '[error_class]', esc_attr( $classes ), $this->html );
438 + $this->html = str_replace( '[error_class]', $classes, $this->html );
440 439 }
441 440
442 441 /**
443 442 * Get the classes for a field div
@@ -453,9 +452,9 @@
453 452 // Add label position class
454 453 $settings = $this->field_obj->display_field_settings();
455 454 if ( isset( $settings['label_position'] ) && $settings['label_position'] ) {
456 455 $label_position = $this->field_obj->get_field_column( 'label' );
457 - $classes .= ' frm_' . $label_position . '_container';
456 + $classes .= ' frm_' . $label_position . '_container';
458 457
459 458 // Add class if field has value, to be used for floating label styling.
460 459 if ( 'inside' === $label_position && $this->field_obj->get_field_column( 'value' ) ) {
461 460 $classes .= ' frm_label_float_top';
@@ -473,14 +472,9 @@
473 472
474 473 $classes .= $this->field_obj->get_container_class();
475 474
476 475 // Get additional classes
477 - $classes = apply_filters( 'frm_field_div_classes', $classes, $this->field_obj->get_field(), array( 'field_id' => $this->field_id ) );
478 -
479 - // Remove unexpected characters from class.
480 - $classes = implode( ' ', array_map( 'FrmFormsHelper::sanitize_layout_class', explode( ' ', $classes ) ) );
481 -
482 - return $classes;
476 + return apply_filters( 'frm_field_div_classes', $classes, $this->field_obj->get_field(), array( 'field_id' => $this->field_id ) );
483 477 }
484 478
485 479 /**
486 480 * This filters shortcodes in the field HTML
@@ -523,13 +517,8 @@
523 517
524 518 // Add 'aria-required' attribute to the field if required.
525 519 if ( $is_radio && '1' === $field['required'] ) {
526 520 $attributes['aria-required'] = 'true';
527 - }
528 -
529 - // Add 'aria-invalid' attribute to the group if there are errors.
530 - if ( isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ) {
531 - $attributes['aria-invalid'] = 'true';
532 521 }
533 522
534 523 // Concatenate attributes into a string, and replace the role="group" in the HTML with the attributes string.
535 524 $html_attributes = FrmAppHelper::array_to_html_params( $attributes );