PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.11
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.11
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/controllers/FrmFieldsController.php +221 -146 6.46.11 View file →
@@ -4,8 +4,15 @@
4 4 }
5 5
6 6 class FrmFieldsController {
7 7
8 + /**
9 + * This is stored statically so we can re-use this data for every field.
10 + *
11 + * @var FrmFieldSelectionData|null
12 + */
13 + private static $field_selection_data;
14 +
8 15 public static function load_field() {
9 16 FrmAppHelper::permission_check( 'frm_edit_forms' );
10 17 check_ajax_referer( 'frm_ajax', 'nonce' );
11 18
@@ -73,18 +80,24 @@
73 80 /**
74 81 * Set up and create a new field
75 82 *
76 83 * @param string $field_type
77 - * @param integer $form_id
84 + * @param int $form_id
78 85 *
79 - * @return array|bool
86 + * @return array|false
80 87 */
81 88 public static function include_new_field( $field_type, $form_id ) {
82 89 $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
90 +
91 + // When a new field is added to the form, flag it as draft and hide it from the front-end.
92 + $field_values['field_options']['draft'] = 1;
93 +
94 + /**
95 + * @param array $field_values
96 + */
83 97 $field_values = apply_filters( 'frm_before_field_created', $field_values );
98 + $field_id = FrmField::create( $field_values );
84 99
85 - $field_id = FrmField::create( $field_values );
86 -
87 100 if ( ! $field_id ) {
88 101 return false;
89 102 }
90 103
@@ -136,11 +149,11 @@
136 149
137 150 /**
138 151 * @since 3.0
139 152 *
140 - * @param int|array|object $field_object
141 - * @param array $values
142 - * @param int $form_id
153 + * @param array|int|object $field_object
154 + * @param array $values
155 + * @param int $form_id
143 156 */
144 157 public static function load_single_field( $field_object, $values, $form_id = 0 ) {
145 158 global $frm_vars;
146 159 $frm_vars['is_admin'] = true;
@@ -154,30 +167,35 @@
154 167
155 168 $field_obj = FrmFieldFactory::get_field_factory( $field_object );
156 169 $display = self::display_field_options( array(), $field_obj );
157 170
158 - $ajax_loading = isset( $values['ajax_load'] ) && $values['ajax_load'];
159 - $ajax_this_field = isset( $values['count'] ) && $values['count'] > 10 && ! in_array( $field_object->type, array( 'divider', 'end_divider' ) );
171 + $ajax_loading = ! empty( $values['ajax_load'] );
172 + $ajax_this_field = isset( $values['count'] ) && $values['count'] > 10 && ! in_array( $field_object->type, array( 'divider', 'end_divider' ), true );
160 173
161 174 if ( $ajax_loading && $ajax_this_field ) {
162 175 $li_classes = self::get_classes_for_builder_field( array(), $display, $field_obj );
163 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/ajax-field-placeholder.php' );
164 - } else {
165 - if ( ! isset( $field ) && is_object( $field_object ) ) {
166 - $field_object->parent_form_id = isset( $values['id'] ) ? $values['id'] : $field_object->form_id;
176 + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/ajax-field-placeholder.php';
177 + return;
178 + }
167 179
168 - $field = FrmFieldsHelper::setup_edit_vars( $field_object );
169 - }
180 + if ( ! isset( $field ) && is_object( $field_object ) ) {
181 + $field_object->parent_form_id = isset( $values['id'] ) ? $values['id'] : $field_object->form_id;
182 + $field = FrmFieldsHelper::setup_edit_vars( $field_object );
183 + }
170 184
171 - $li_classes = self::get_classes_for_builder_field( $field, $display, $field_obj );
172 - $li_classes .= ' ui-state-default widgets-holder-wrap';
185 + $li_classes = self::get_classes_for_builder_field( $field, $display, $field_obj );
186 + $li_classes .= ' ui-state-default widgets-holder-wrap';
173 187
174 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
175 - }
188 + require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php';
176 189 }
177 190
178 191 /**
179 192 * @since 3.0
193 + *
194 + * @param array $field
195 + * @param array $display
196 + * @param FrmFieldType $field_info
197 + * @return string
180 198 */
181 199 private static function get_classes_for_builder_field( $field, $display, $field_info ) {
182 200 $li_classes = $field_info->form_builder_classes( $display['type'] );
183 201 $li_classes .= ' frm_form_field frmstart ';
@@ -203,10 +221,11 @@
203 221 FrmField::destroy( $field_id );
204 222 wp_die();
205 223 }
206 224
207 - /* Field Options */
208 -
225 + /**
226 + * Field Options.
227 + */
209 228 public static function import_options() {
210 229 FrmAppHelper::permission_check( 'frm_edit_forms' );
211 230 check_ajax_referer( 'frm_ajax', 'nonce' );
212 231
@@ -213,12 +232,23 @@
213 232 if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
214 233 return;
215 234 }
216 235
217 - $field_id = FrmAppHelper::get_param( 'field_id', '', 'post', 'absint' );
218 - $field = FrmField::getOne( $field_id );
236 + $field_id = FrmAppHelper::get_param( 'field_id', '', 'post', 'absint' );
237 + $field = FrmField::getOne( $field_id );
238 + $bulk_edit_types = array( 'radio', 'checkbox', 'select' );
219 239
220 - if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
240 + /**
241 + * Filter to add new fields that will support import_options/Bulk Edit Options.
242 + *
243 + * @since 6.8.4
244 + *
245 + * @param array $bulk_edit_types
246 + * @return array
247 + */
248 + $bulk_edit_types = apply_filters( 'frm_bulk_edit_field_types', $bulk_edit_types );
249 +
250 + if ( ! in_array( $field->type, $bulk_edit_types, true ) ) {
221 251 return;
222 252 }
223 253
224 254 $field = FrmFieldsHelper::setup_edit_vars( $field );
@@ -225,15 +255,15 @@
225 255 $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
226 256 $opts = explode( "\n", rtrim( $opts, "\n" ) );
227 257 $opts = array_map( 'trim', $opts );
228 258
229 - $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' );
230 - $field['separate_value'] = ( $separate === 'true' );
259 + $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' );
260 + $field['separate_value'] = $separate === 'true';
231 261
232 262 if ( $field['separate_value'] ) {
233 263 foreach ( $opts as $opt_key => $opt ) {
234 264 if ( strpos( $opt, '|' ) !== false ) {
235 - $vals = explode( '|', $opt );
265 + $vals = explode( '|', $opt );
236 266 $opts[ $opt_key ] = array(
237 267 'label' => trim( $vals[0] ),
238 268 'value' => trim( $vals[1] ),
239 269 );
@@ -267,8 +297,9 @@
267 297 /**
268 298 * @since 4.0
269 299 *
270 300 * @param array $atts - Includes field array, field_obj, display array, values array.
301 + * @return void
271 302 */
272 303 public static function load_single_field_settings( $atts ) {
273 304 $field = $atts['field'];
274 305 $field_obj = $atts['field_obj'];
@@ -283,13 +314,13 @@
283 314 if ( ! isset( $field['read_only'] ) ) {
284 315 $field['read_only'] = false;
285 316 }
286 317
287 - $field_types = FrmFieldsHelper::get_field_types( $field['type'] );
288 - $pro_field_selection = FrmField::pro_field_selection();
289 - $all_field_types = array_merge( $pro_field_selection, FrmField::field_selection() );
290 - $disabled_fields = FrmAppHelper::pro_is_installed() ? array() : $pro_field_selection;
291 - $frm_settings = FrmAppHelper::get_settings();
318 + $field_selection_data = self::maybe_define_field_selection_data();
319 + $all_field_types = $field_selection_data->all_field_types;
320 + $disabled_fields = $field_selection_data->disabled_fields;
321 + $frm_settings = FrmAppHelper::get_settings();
322 + $field_types = FrmFieldTypeOptionData::get_field_types( $field['type'] );
292 323
293 324 if ( ! isset( $all_field_types[ $field['type'] ] ) ) {
294 325 // Add fallback for an add-on field type that has been deactivated.
295 326 $all_field_types[ $field['type'] ] = array(
@@ -312,20 +343,36 @@
312 343
313 344 if ( $display['clear_on_focus'] && is_array( $field['placeholder'] ) ) {
314 345 $field['placeholder'] = implode( ', ', $field['placeholder'] );
315 346 }
316 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php' );
347 +
348 + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php';
317 349 }
318 350
319 351 /**
352 + * @since 6.9.1
353 + *
354 + * @return FrmFieldSelectionData
355 + */
356 + private static function maybe_define_field_selection_data() {
357 + if ( ! isset( self::$field_selection_data ) ) {
358 + self::$field_selection_data = new FrmFieldSelectionData();
359 + }
360 + return self::$field_selection_data;
361 + }
362 +
363 + /**
320 364 * Get the list of default value types that can be toggled in the builder.
321 365 *
322 366 * @since 4.0
367 + *
368 + * @param array $field
369 + * @param array $atts
323 370 * @return array
324 371 */
325 372 private static function default_value_types( $field, $atts ) {
326 373 $types = array(
327 - 'default_value' => array(
374 + 'default_value' => array(
328 375 'class' => '',
329 376 'icon' => 'frm_icon_font frm_text2_icon',
330 377 'title' => __( 'Default Value (Text)', 'formidable' ),
331 378 'data' => array(
@@ -331,9 +378,9 @@
331 378 'data' => array(
332 379 'frmshow' => '#default-value-for-',
333 380 ),
334 381 ),
335 - 'calc' => array(
382 + 'calc' => array(
336 383 'class' => 'frm_show_upgrade frm_noallow',
337 384 'title' => __( 'Default Value (Calculation)', 'formidable' ),
338 385 'icon' => 'frm_icon_font frm_calculator_icon',
339 386 'data' => array(
@@ -353,13 +400,8 @@
353 400 );
354 401
355 402 $types = apply_filters( 'frm_default_value_types', $types, $atts );
356 403
357 - if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
358 - // Prevent settings from showing in 2 spots.
359 - unset( $types['calc'], $types['get_values_field'] );
360 - }
361 -
362 404 // Set active class.
363 405 $settings = array_keys( $types );
364 406 $active = 'default_value';
365 407
@@ -374,8 +416,12 @@
374 416
375 417 return $types;
376 418 }
377 419
420 + /**
421 + * @param string $type
422 + * @return string
423 + */
378 424 public static function change_type( $type ) {
379 425 $type_switch = array(
380 426 'scale' => 'radio',
381 427 'star' => 'radio',
@@ -388,10 +434,13 @@
388 434 $type = $type_switch[ $type ];
389 435 }
390 436
391 437 $pro_fields = FrmField::pro_field_selection();
392 - $types = array_keys( $pro_fields );
393 - if ( in_array( $type, $types ) ) {
438 + // We want to keep credit_card types as credit card types for Stripe Lite.
439 + // The credit_card key is set for backward compatibility.
440 + unset( $pro_fields['credit_card'] );
441 +
442 + if ( array_key_exists( $type, $pro_fields ) ) {
394 443 $type = 'text';
395 444 }
396 445
397 446 return $type;
@@ -397,10 +446,10 @@
397 446 return $type;
398 447 }
399 448
400 449 /**
401 - * @param array $settings
402 - * @param object $field_info
450 + * @param array $settings
451 + * @param object|null $field_info
403 452 *
404 453 * @return array
405 454 */
406 455 public static function display_field_options( $settings, $field_info = null ) {
@@ -417,11 +466,20 @@
417 466 *
418 467 * @since 3.0
419 468 *
420 469 * @param array $field
470 + * @return void
421 471 */
422 472 public static function show_format_option( $field ) {
423 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' );
473 + $attributes = array();
474 + $attributes['class'] = 'frm-has-modal';
475 +
476 + if ( 'phone' === $field['type'] ) {
477 + $attributes['id'] = 'frm-phone-field-custom-format-' . $field['id'];
478 + $attributes['class'] .= ' frm_hidden';
479 + }
480 +
481 + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php';
424 482 }
425 483
426 484 public static function input_html( $field, $echo = true ) {
427 485 $class = array();
@@ -449,14 +507,19 @@
449 507
450 508 return $add_html;
451 509 }
452 510
511 + /**
512 + * @param array $field
513 + * @param array $class
514 + * @return void
515 + */
453 516 private static function add_input_classes( $field, array &$class ) {
454 - if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
517 + if ( ! empty( $field['input_class'] ) ) {
455 518 $class[] = $field['input_class'];
456 519 }
457 520
458 - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
521 + if ( $field['type'] === 'hidden' || $field['type'] === 'user_id' ) {
459 522 return;
460 523 }
461 524
462 525 if ( isset( $field['size'] ) && $field['size'] > 0 ) {
@@ -463,8 +526,13 @@
463 526 $class[] = 'auto_width';
464 527 }
465 528 }
466 529
530 + /**
531 + * @param array $field
532 + * @param array $add_html
533 + * @return void
534 + */
467 535 private static function add_html_size( $field, array &$add_html ) {
468 536 $size_fields = array(
469 537 'select',
470 538 'data',
@@ -473,9 +541,9 @@
473 541 'file',
474 542 'lookup',
475 543 );
476 544
477 - if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], $size_fields ) ) {
545 + if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], $size_fields, true ) ) {
478 546 return;
479 547 }
480 548
481 549 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -492,10 +560,15 @@
492 560
493 561 self::add_html_cols( $field, $add_html );
494 562 }
495 563
564 + /**
565 + * @param array $field
566 + * @param array $add_html
567 + * @return void
568 + */
496 569 private static function add_html_cols( $field, array &$add_html ) {
497 - if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
570 + if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) {
498 571 return;
499 572 }
500 573
501 574 // Convert to cols for textareas.
@@ -517,8 +590,13 @@
517 590
518 591 $add_html['cols'] = 'cols="' . absint( $size ) . '"';
519 592 }
520 593
594 + /**
595 + * @param array $field
596 + * @param array $add_html
597 + * @return void
598 + */
521 599 private static function add_html_length( $field, array &$add_html ) {
522 600 // Check for max setting and if this field accepts maxlength.
523 601 $fields = array(
524 602 'textarea',
@@ -526,9 +604,9 @@
526 604 'hidden',
527 605 'file',
528 606 );
529 607
530 - if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], $fields ) ) {
608 + if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], $fields, true ) ) {
531 609 return;
532 610 }
533 611
534 612 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -538,8 +616,14 @@
538 616
539 617 $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
540 618 }
541 619
620 + /**
621 + * @param array $field
622 + * @param array $add_html
623 + * @param array $class
624 + * @return void
625 + */
542 626 private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
543 627 if ( $field['default_value'] != '' ) {
544 628 if ( is_array( $field['default_value'] ) ) {
545 629 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( json_encode( $field['default_value'] ) ) . '"';
@@ -610,14 +694,31 @@
610 694 if ( empty( $placeholder ) ) {
611 695 $placeholder = self::get_default_value_from_name( $field );
612 696 }
613 697
698 + $use_placeholder = $placeholder;
699 + $autocomplete = FrmField::get_option( $field, 'autocom' );
700 +
701 + if ( $autocomplete ) {
702 + $use_chosen = ! is_callable( 'FrmProAppHelper::use_chosen_js' ) || FrmProAppHelper::use_chosen_js();
703 + if ( $use_chosen ) {
704 + $use_placeholder = '';
705 + }
706 + }
707 +
614 708 if ( $placeholder !== '' ) {
615 - ?>
616 - <option value="">
617 - <?php echo esc_html( FrmField::get_option( $field, 'autocom' ) ? '' : $placeholder ); ?>
618 - </option>
619 - <?php
709 + $placeholder_attributes = array(
710 + 'class' => 'frm-select-placeholder',
711 + 'value' => '',
712 + 'data-placeholder' => 'true',
713 + );
714 +
715 + if ( $autocomplete && empty( $use_chosen ) ) {
716 + // This is required for Slim Select.
717 + $placeholder_attributes['data-placeholder'] = 'true';
718 + }
719 +
720 + FrmHtmlHelper::echo_dropdown_option( $use_placeholder, false, $placeholder_attributes );
620 721 return true;
621 722 }
622 723
623 724 return false;
@@ -623,12 +724,13 @@
623 724 return false;
624 725 }
625 726
626 727 /**
627 - * Use HMTL5 placeholder with js fallback
728 + * Use HMTL5 placeholder with js fallback.
628 729 *
629 730 * @param array $field
630 731 * @param array $add_html
732 + * @return void
631 733 */
632 734 private static function add_placeholder_to_input( $field, &$add_html ) {
633 735 if ( FrmFieldsHelper::is_placeholder_field_type( $field['type'] ) ) {
634 736 $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['placeholder'] ) . '"';
@@ -634,8 +736,13 @@
634 736 $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['placeholder'] ) . '"';
635 737 }
636 738 }
637 739
740 + /**
741 + * @param array $field
742 + * @param array $add_html
743 + * @return void
744 + */
638 745 private static function add_frmval_to_input( $field, &$add_html ) {
639 746 if ( $field['placeholder'] != '' ) {
640 747 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['placeholder'] ) . '"';
641 748
@@ -649,15 +756,17 @@
649 756 }
650 757 }
651 758
652 759 private static function add_validation_messages( $field, array &$add_html ) {
653 - if ( FrmField::is_required( $field ) ) {
760 + $field_validation_messages_status = self::get_validation_data_attribute_visibility_info( $field );
761 +
762 + if ( FrmField::is_required( $field ) && ! empty( $field_validation_messages_status['data-reqmsg'] ) ) {
654 763 $required_message = FrmFieldsHelper::get_error_msg( $field, 'blank' );
655 764 $add_html['data-reqmsg'] = 'data-reqmsg="' . esc_attr( $required_message ) . '"';
656 765 self::maybe_add_html_required( $field, $add_html );
657 766 }
658 767
659 - if ( ! FrmField::is_option_empty( $field, 'invalid' ) ) {
768 + if ( ! FrmField::is_option_empty( $field, 'invalid' ) && ! empty( $field_validation_messages_status['data-invmsg'] ) ) {
660 769 $invalid_message = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
661 770 $add_html['data-invmsg'] = 'data-invmsg="' . esc_attr( $invalid_message ) . '"';
662 771 }
663 772
@@ -666,12 +775,45 @@
666 775 }
667 776 }
668 777
669 778 /**
779 + * Returns an array that contains field validation messages status.
780 + *
781 + * @since 6.9
782 + *
783 + * @param array|object $field
784 + * @return array
785 + */
786 + private static function get_validation_data_attribute_visibility_info( $field ) {
787 + if ( FrmField::get_field_type( $field ) === 'hidden' ) {
788 + $field_validation_data_attributes = array(
789 + 'data-invmsg' => false,
790 + 'data-reqmsg' => false,
791 + );
792 + } else {
793 + $field_validation_data_attributes = array(
794 + 'data-invmsg' => true,
795 + 'data-reqmsg' => true,
796 + );
797 + }
798 +
799 + /**
800 + * Allows controlling which field validation messages would be included in the field html.
801 + *
802 + * @since 6.9
803 + *
804 + * @param array $field_validation_messages_status
805 + * @param array|object $field
806 + */
807 + return apply_filters( 'frm_field_validation_include_data_attributes', $field_validation_data_attributes, $field );
808 + }
809 +
810 + /**
670 811 * @since 5.0.03
671 812 *
672 813 * @param array $field
673 814 * @param array $add_html
815 + * @return void
674 816 */
675 817 private static function maybe_add_error_html_for_js_validation( $field, array &$add_html ) {
676 818 $form = self::get_form_for_js_validation( $field );
677 819 if ( false === $form ) {
@@ -688,9 +830,9 @@
688 830 /**
689 831 * @since 5.0.03
690 832 *
691 833 * @param array $field
692 - * @return stdClass|false false if there is no form object found with JS validation active.
834 + * @return false|stdClass false if there is no form object found with JS validation active.
693 835 */
694 836 private static function get_form_for_js_validation( $field ) {
695 837 global $frm_vars;
696 838 if ( ! empty( $frm_vars['js_validate_forms'] ) ) {
@@ -707,9 +849,9 @@
707 849 /**
708 850 * @param stdClass $form
709 851 * @param array $field
710 852 * @param array $errors
711 - * @return string|false
853 + * @return false|string
712 854 */
713 855 public static function pull_custom_error_body_from_custom_html( $form, $field, $errors = array() ) {
714 856 if ( empty( $field['custom_html'] ) ) {
715 857 return false;
@@ -750,20 +892,30 @@
750 892 *
751 893 * @since 3.06.01
752 894 * @param array $field
753 895 * @param array $add_html
896 + * @return void
754 897 */
755 898 private static function maybe_add_html_required( $field, array &$add_html ) {
756 - if ( in_array( $field['type'], array( 'file', 'data', 'lookup' ), true ) ) {
899 + $excluded_field_types =
900 + FrmField::is_radio( $field ) ||
901 + FrmField::is_checkbox( $field ) ||
902 + FrmField::is_field_type( $field, 'file' ) ||
903 + FrmField::is_field_type( $field, 'nps' ) ||
904 + FrmField::is_field_type( $field, 'scale' );
905 +
906 + if ( $excluded_field_types ) {
757 907 return;
758 908 }
759 909
760 - $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' );
761 - if ( $include_html ) {
762 - $add_html['aria-required'] = 'aria-required="true"';
763 - }
910 + $add_html['aria-required'] = 'aria-required="true"';
764 911 }
765 912
913 + /**
914 + * @param array $field
915 + * @param array $add_html
916 + * @return void
917 + */
766 918 private static function add_shortcodes_to_html( $field, array &$add_html ) {
767 919 if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
768 920 return;
769 921 }
@@ -789,20 +941,21 @@
789 941 }
790 942 }
791 943
792 944 /**
793 - * Add pattern attribute
945 + * Add pattern attribute.
794 946 *
795 947 * @since 3.0
796 948 *
797 949 * @param array $field
798 950 * @param array $add_html
951 + * @return void
799 952 */
800 953 private static function add_pattern_attribute( $field, array &$add_html ) {
801 954 $has_format = FrmField::is_option_true_in_array( $field, 'format' );
802 955 $format_field = FrmField::is_field_type( $field, 'text' );
803 956
804 - if ( $field['type'] == 'phone' || ( $has_format && $format_field ) ) {
957 + if ( $field['type'] === 'phone' || ( $has_format && $format_field ) ) {
805 958 $frm_settings = FrmAppHelper::get_settings();
806 959
807 960 if ( $frm_settings->use_html ) {
808 961 $format = FrmEntryValidate::phone_format( $field );
@@ -826,88 +979,10 @@
826 979 }
827 980
828 981 public static function check_label( $opt ) {
829 982 if ( is_array( $opt ) ) {
830 - $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
983 + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
831 984 }
832 985
833 986 return $opt;
834 - }
835 -
836 - /**
837 - * @deprecated 4.0
838 - */
839 - public static function update_ajax_option() {
840 - _deprecated_function( __METHOD__, '4.0' );
841 - FrmAppHelper::permission_check( 'frm_edit_forms' );
842 - check_ajax_referer( 'frm_ajax', 'nonce' );
843 -
844 - $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
845 - if ( ! $field_id ) {
846 - wp_die();
847 - }
848 -
849 - $field = FrmField::getOne( $field_id );
850 -
851 - if ( isset( $_POST['separate_value'] ) ) {
852 - $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
853 -
854 - $field->field_options['separate_value'] = $new_val;
855 - unset( $new_val );
856 - }
857 -
858 - FrmField::update(
859 - $field_id,
860 - array(
861 - 'field_options' => $field->field_options,
862 - 'form_id' => $field->form_id,
863 - )
864 - );
865 - wp_die();
866 - }
867 -
868 - /**
869 - * @deprecated 4.0
870 - */
871 - public static function import_choices() {
872 - _deprecated_function( __METHOD__, '4.0' );
873 - wp_die();
874 - }
875 -
876 - /**
877 - * Add Single Option or Other Option.
878 - *
879 - * @deprecated 4.0 Moved to Pro for Other option only.
880 - */
881 - public static function add_option() {
882 - _deprecated_function( __METHOD__, '4.0', 'FrmProFieldsController::add_other_option' );
883 - }
884 -
885 - /**
886 - * @deprecated 4.0
887 - */
888 - public static function update_order() {
889 - FrmDeprecated::update_order();
890 - }
891 -
892 - /**
893 - * @deprecated 3.0
894 - * @codeCoverageIgnore
895 - */
896 - public static function edit_name( $field = 'name', $id = '' ) {
897 - FrmDeprecated::edit_name( $field, $id );
898 - }
899 -
900 - /**
901 - * @deprecated 3.0
902 - * @codeCoverageIgnore
903 - *
904 - * @param int $field_id
905 - * @param array $values
906 - * @param int $form_id
907 - *
908 - * @return array
909 - */
910 - public static function include_single_field( $field_id, $values, $form_id = 0 ) {
911 - return FrmDeprecated::include_single_field( $field_id, $values, $form_id );
912 987 }
913 988 }