PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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 +20 -34 6.4.26.13 View file →
@@ -5,9 +5,8 @@
5 5
6 6 /**
7 7 * @since 3.0
8 8 */
9 -
10 9 class FrmFieldFormHtml {
11 10
12 11 private $html;
13 12
@@ -41,9 +40,9 @@
41 40 /**
42 41 * @since 3.0
43 42 *
44 43 * @param string $param
45 - * @param array $atts
44 + * @param array $atts
46 45 */
47 46 private function _set( $param, $atts ) {
48 47 if ( isset( $atts[ $param ] ) ) {
49 48 $this->{$param} = $atts[ $param ];
@@ -144,18 +143,18 @@
144 143 /**
145 144 * @since 3.0
146 145 */
147 146 private function replace_field_values() {
148 - //replace [id]
147 + // Replace [id].
149 148 $this->html = str_replace( '[id]', $this->field_id, $this->html );
150 149
151 150 // set the label for
152 151 $this->html = str_replace( 'field_[key]', $this->html_id, $this->html );
153 152
154 - //replace [key]
153 + // Replace [key].
155 154 $this->html = str_replace( '[key]', $this->field_obj->get_field_column( 'field_key' ), $this->html );
156 155
157 - //replace [field_name]
156 + // Replace [field_name].
158 157 $this->html = str_replace( '[field_name]', FrmAppHelper::maybe_kses( $this->field_obj->get_field_column( 'name' ) ), $this->html );
159 158 }
160 159
161 160 /**
@@ -219,9 +218,9 @@
219 218
220 219 if ( is_string( $inner_html[2] ) ) {
221 220 $has_id = strpos( $inner_html[2], ' id=' );
222 221 if ( ! $has_id ) {
223 - $id = 'frm_' . $id . '_' . $this->html_id;
222 + $id = 'frm_' . $id . '_' . $this->html_id;
224 223 $this->html = str_replace( 'class="frm_' . $param, 'id="' . esc_attr( $id ) . '" class="frm_' . esc_attr( $param ), $this->html );
225 224 }
226 225 }
227 226 }
@@ -247,9 +246,9 @@
247 246 /**
248 247 * Pull the HTML between [if error] and [/if error] shortcodes.
249 248 *
250 249 * @param string $html
251 - * @return string|false
250 + * @return false|string
252 251 */
253 252 private static function get_error_body( $html ) {
254 253 $start = strpos( $html, '[if error]' );
255 254 if ( false === $start ) {
@@ -295,12 +294,12 @@
295 294 private function replace_form_shortcodes() {
296 295 if ( ! empty( $this->form ) ) {
297 296 $form = (array) $this->form;
298 297
299 - //replace [form_key]
298 + // Replace [form_key].
300 299 $this->html = str_replace( '[form_key]', $form['form_key'], $this->html );
301 300
302 - //replace [form_name]
301 + // Replace [form_name].
303 302 $this->html = str_replace( '[form_name]', $form['name'], $this->html );
304 303 }
305 304 }
306 305
@@ -321,9 +320,9 @@
321 320 */
322 321 private function filter_for_more_shortcodes() {
323 322 $atts = $this->pass_args;
324 323
325 - //If field is not in repeating section
324 + // If field is not in repeating section.
326 325 if ( empty( $atts['section_id'] ) ) {
327 326 $atts = array(
328 327 'errors' => $this->pass_args['errors'],
329 328 'form' => $this->form,
@@ -356,11 +355,11 @@
356 355 $tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
357 356
358 357 $replace_with = '';
359 358
360 - if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
359 + if ( $tag === 'deletelink' && FrmAppHelper::pro_is_installed() ) {
361 360 $replace_with = FrmProEntriesController::entry_delete_link( $shortcode_atts );
362 - } elseif ( $tag == 'input' ) {
361 + } elseif ( $tag === 'input' ) {
363 362 $replace_with = $this->replace_input_shortcode( $shortcode_atts );
364 363 }
365 364
366 365 $this->html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $this->html );
@@ -384,9 +383,9 @@
384 383 * @return array
385 384 */
386 385 private function prepare_input_shortcode_atts( $shortcode_atts ) {
387 386 if ( isset( $shortcode_atts['opt'] ) ) {
388 - $shortcode_atts['opt'] --;
387 + --$shortcode_atts['opt'];
389 388 }
390 389
391 390 $field_class = isset( $shortcode_atts['class'] ) ? $shortcode_atts['class'] : '';
392 391 $this->field_obj->set_field_column( 'input_class', $field_class );
@@ -430,9 +429,9 @@
430 429 */
431 430 private function add_field_div_classes() {
432 431 $classes = $this->get_field_div_classes();
433 432
434 - if ( $this->field_obj->get_field_column( 'type' ) == 'html' && strpos( $this->html, '[error_class]' ) === false ) {
433 + if ( $this->field_obj->get_field_column( 'type' ) === 'html' && strpos( $this->html, '[error_class]' ) === false ) {
435 434 // there is no error_class shortcode for HTML fields
436 435 $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $classes, $this->html );
437 436 }
438 437 $this->html = str_replace( '[error_class]', $classes, $this->html );
@@ -452,9 +451,9 @@
452 451 // Add label position class
453 452 $settings = $this->field_obj->display_field_settings();
454 453 if ( isset( $settings['label_position'] ) && $settings['label_position'] ) {
455 454 $label_position = $this->field_obj->get_field_column( 'label' );
456 - $classes .= ' frm_' . $label_position . '_container';
455 + $classes .= ' frm_' . $label_position . '_container';
457 456
458 457 // Add class if field has value, to be used for floating label styling.
459 458 if ( 'inside' === $label_position && $this->field_obj->get_field_column( 'value' ) ) {
460 459 $classes .= ' frm_label_float_top';
@@ -500,25 +499,17 @@
500 499 if ( ! in_array( $field_type, array( 'radio', 'checkbox', 'data', 'product', 'scale' ), true ) ) {
501 500 return;
502 501 }
503 502
504 - $field = (array) $this->field_obj->get_field();
505 - $attributes = array();
506 - $is_radio = 'radio' === $field_type || 'scale' === $field_type;
507 - $type_requires_aria_required = true;
503 + $field = (array) $this->field_obj->get_field();
504 + $attributes = array();
508 505
509 506 // Check if the field type is 'data' or 'product'.
510 507 if ( in_array( $field_type, array( 'data', 'product' ), true ) ) {
511 508 $data_type = FrmField::get_option( $field, 'data_type' );
512 - // Check if the data type isn't 'radio' or 'checkbox'.
513 - if ( 'radio' !== $data_type && 'checkbox' !== $data_type ) {
514 - // If data type aren't 'radio' or 'checkbox', doesn't need to add 'aria-required' to multiple input container.
515 - $type_requires_aria_required = false;
516 - }
517 - // Check if data type is 'radio'
518 - if ( 'radio' === $data_type ) {
519 - $is_radio = true;
520 - }
509 + $is_radio = 'radio' === $data_type;
510 + } else {
511 + $is_radio = 'radio' === $field_type || 'scale' === $field_type;
521 512 }
522 513
523 514 // Add 'role' attribute to the field.
524 515 $attributes['role'] = $is_radio ? 'radiogroup' : 'group';
@@ -523,15 +514,10 @@
523 514 // Add 'role' attribute to the field.
524 515 $attributes['role'] = $is_radio ? 'radiogroup' : 'group';
525 516
526 517 // Add 'aria-required' attribute to the field if required.
527 - if ( $type_requires_aria_required && '1' === $field['required'] ) {
518 + if ( $is_radio && '1' === $field['required'] ) {
528 519 $attributes['aria-required'] = 'true';
529 - }
530 -
531 - // Add 'tabindex = "0"' attribute to the radio field.
532 - if ( $is_radio ) {
533 - $attributes['tabindex'] = 0;
534 520 }
535 521
536 522 // Concatenate attributes into a string, and replace the role="group" in the HTML with the attributes string.
537 523 $html_attributes = FrmAppHelper::array_to_html_params( $attributes );