| @@ -79,12 +79,15 @@ | ||
| 79 | 79 | * @return array|bool |
| 80 | 80 | */ |
| 81 | 81 | public static function include_new_field( $field_type, $form_id ) { |
| 82 | 82 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 83 | + | |
| 84 | + /** | |
| 85 | + * @param array $field_values | |
| 86 | + */ | |
| 83 | 87 | $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
| 88 | + $field_id = FrmField::create( $field_values ); | |
| 84 | 89 | |
| 85 | - $field_id = FrmField::create( $field_values ); | |
| 86 | - | |
| 87 | 90 | if ( ! $field_id ) { |
| 88 | 91 | return false; |
| 89 | 92 | } |
| 90 | 93 | |
| @@ -312,9 +315,10 @@ | ||
| 312 | 315 | |
| 313 | 316 | if ( $display['clear_on_focus'] && is_array( $field['placeholder'] ) ) { |
| 314 | 317 | $field['placeholder'] = implode( ', ', $field['placeholder'] ); |
| 315 | 318 | } |
| 316 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php' ); | |
| 319 | + | |
| 320 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php'; | |
| 317 | 321 | } |
| 318 | 322 | |
| 319 | 323 | /** |
| 320 | 324 | * Get the list of default value types that can be toggled in the builder. |
| @@ -388,10 +392,13 @@ | ||
| 388 | 392 | $type = $type_switch[ $type ]; |
| 389 | 393 | } |
| 390 | 394 | |
| 391 | 395 | $pro_fields = FrmField::pro_field_selection(); |
| 392 | - $types = array_keys( $pro_fields ); | |
| 393 | - if ( in_array( $type, $types ) ) { | |
| 396 | + // We want to keep credit_card types as credit card types for Stripe Lite. | |
| 397 | + // The credit_card key is set for backward compatibility. | |
| 398 | + unset( $pro_fields['credit_card'] ); | |
| 399 | + | |
| 400 | + if ( array_key_exists( $type, $pro_fields ) ) { | |
| 394 | 401 | $type = 'text'; |
| 395 | 402 | } |
| 396 | 403 | |
| 397 | 404 | return $type; |
| @@ -493,9 +500,9 @@ | ||
| 493 | 500 | self::add_html_cols( $field, $add_html ); |
| 494 | 501 | } |
| 495 | 502 | |
| 496 | 503 | private static function add_html_cols( $field, array &$add_html ) { |
| 497 | - if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { | |
| 504 | + if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) { | |
| 498 | 505 | return; |
| 499 | 506 | } |
| 500 | 507 | |
| 501 | 508 | // Convert to cols for textareas. |
| @@ -612,9 +619,9 @@ | ||
| 612 | 619 | } |
| 613 | 620 | |
| 614 | 621 | if ( $placeholder !== '' ) { |
| 615 | 622 | ?> |
| 616 | - <option value=""> | |
| 623 | + <option class="frm-select-placeholder" value=""> | |
| 617 | 624 | <?php echo esc_html( FrmField::get_option( $field, 'autocom' ) ? '' : $placeholder ); ?> |
| 618 | 625 | </option> |
| 619 | 626 | <?php |
| 620 | 627 | return true; |
| @@ -752,9 +759,16 @@ | ||
| 752 | 759 | * @param array $field |
| 753 | 760 | * @param array $add_html |
| 754 | 761 | */ |
| 755 | 762 | private static function maybe_add_html_required( $field, array &$add_html ) { |
| 756 | - if ( in_array( $field['type'], array( 'file', 'data', 'lookup' ), true ) ) { | |
| 763 | + $excluded_field_types = | |
| 764 | + FrmField::is_radio( $field ) || | |
| 765 | + FrmField::is_checkbox( $field ) || | |
| 766 | + FrmField::is_field_type( $field, 'file' ) || | |
| 767 | + FrmField::is_field_type( $field, 'nps' ) || | |
| 768 | + FrmField::is_field_type( $field, 'scale' ); | |
| 769 | + | |
| 770 | + if ( $excluded_field_types ) { | |
| 757 | 771 | return; |
| 758 | 772 | } |
| 759 | 773 | |
| 760 | 774 | $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' ); |