| @@ -72,9 +72,9 @@ | ||
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Set up and create a new field |
| 75 | 75 | * |
| 76 | - * @param string $field_type | |
| 76 | + * @param string $field_type | |
| 77 | 77 | * @param integer $form_id |
| 78 | 78 | * |
| 79 | 79 | * @return array|bool |
| 80 | 80 | */ |
| @@ -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 | |
| @@ -137,10 +140,10 @@ | ||
| 137 | 140 | /** |
| 138 | 141 | * @since 3.0 |
| 139 | 142 | * |
| 140 | 143 | * @param int|array|object $field_object |
| 141 | - * @param array $values | |
| 142 | - * @param int $form_id | |
| 144 | + * @param array $values | |
| 145 | + * @param int $form_id | |
| 143 | 146 | */ |
| 144 | 147 | public static function load_single_field( $field_object, $values, $form_id = 0 ) { |
| 145 | 148 | global $frm_vars; |
| 146 | 149 | $frm_vars['is_admin'] = true; |
| @@ -203,10 +206,11 @@ | ||
| 203 | 206 | FrmField::destroy( $field_id ); |
| 204 | 207 | wp_die(); |
| 205 | 208 | } |
| 206 | 209 | |
| 207 | - /* Field Options */ | |
| 208 | - | |
| 210 | + /** | |
| 211 | + * Field Options. | |
| 212 | + */ | |
| 209 | 213 | public static function import_options() { |
| 210 | 214 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 211 | 215 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 212 | 216 | |
| @@ -312,9 +316,10 @@ | ||
| 312 | 316 | |
| 313 | 317 | if ( $display['clear_on_focus'] && is_array( $field['placeholder'] ) ) { |
| 314 | 318 | $field['placeholder'] = implode( ', ', $field['placeholder'] ); |
| 315 | 319 | } |
| 316 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php' ); | |
| 320 | + | |
| 321 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php'; | |
| 317 | 322 | } |
| 318 | 323 | |
| 319 | 324 | /** |
| 320 | 325 | * Get the list of default value types that can be toggled in the builder. |
| @@ -388,10 +393,13 @@ | ||
| 388 | 393 | $type = $type_switch[ $type ]; |
| 389 | 394 | } |
| 390 | 395 | |
| 391 | 396 | $pro_fields = FrmField::pro_field_selection(); |
| 392 | - $types = array_keys( $pro_fields ); | |
| 393 | - if ( in_array( $type, $types ) ) { | |
| 397 | + // We want to keep credit_card types as credit card types for Stripe Lite. | |
| 398 | + // The credit_card key is set for backward compatibility. | |
| 399 | + unset( $pro_fields['credit_card'] ); | |
| 400 | + | |
| 401 | + if ( array_key_exists( $type, $pro_fields ) ) { | |
| 394 | 402 | $type = 'text'; |
| 395 | 403 | } |
| 396 | 404 | |
| 397 | 405 | return $type; |
| @@ -397,9 +405,9 @@ | ||
| 397 | 405 | return $type; |
| 398 | 406 | } |
| 399 | 407 | |
| 400 | 408 | /** |
| 401 | - * @param array $settings | |
| 409 | + * @param array $settings | |
| 402 | 410 | * @param object $field_info |
| 403 | 411 | * |
| 404 | 412 | * @return array |
| 405 | 413 | */ |
| @@ -493,9 +501,9 @@ | ||
| 493 | 501 | self::add_html_cols( $field, $add_html ); |
| 494 | 502 | } |
| 495 | 503 | |
| 496 | 504 | private static function add_html_cols( $field, array &$add_html ) { |
| 497 | - if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { | |
| 505 | + if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) { | |
| 498 | 506 | return; |
| 499 | 507 | } |
| 500 | 508 | |
| 501 | 509 | // Convert to cols for textareas. |
| @@ -612,9 +620,9 @@ | ||
| 612 | 620 | } |
| 613 | 621 | |
| 614 | 622 | if ( $placeholder !== '' ) { |
| 615 | 623 | ?> |
| 616 | - <option value=""> | |
| 624 | + <option class="frm-select-placeholder" value=""> | |
| 617 | 625 | <?php echo esc_html( FrmField::get_option( $field, 'autocom' ) ? '' : $placeholder ); ?> |
| 618 | 626 | </option> |
| 619 | 627 | <?php |
| 620 | 628 | return true; |
| @@ -752,9 +760,16 @@ | ||
| 752 | 760 | * @param array $field |
| 753 | 761 | * @param array $add_html |
| 754 | 762 | */ |
| 755 | 763 | private static function maybe_add_html_required( $field, array &$add_html ) { |
| 756 | - if ( in_array( $field['type'], array( 'file', 'data', 'lookup' ), true ) ) { | |
| 764 | + $excluded_field_types = | |
| 765 | + FrmField::is_radio( $field ) || | |
| 766 | + FrmField::is_checkbox( $field ) || | |
| 767 | + FrmField::is_field_type( $field, 'file' ) || | |
| 768 | + FrmField::is_field_type( $field, 'nps' ) || | |
| 769 | + FrmField::is_field_type( $field, 'scale' ); | |
| 770 | + | |
| 771 | + if ( $excluded_field_types ) { | |
| 757 | 772 | return; |
| 758 | 773 | } |
| 759 | 774 | |
| 760 | 775 | $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' ); |
| @@ -900,11 +915,11 @@ | ||
| 900 | 915 | /** |
| 901 | 916 | * @deprecated 3.0 |
| 902 | 917 | * @codeCoverageIgnore |
| 903 | 918 | * |
| 904 | - * @param int $field_id | |
| 919 | + * @param int $field_id | |
| 905 | 920 | * @param array $values |
| 906 | - * @param int $form_id | |
| 921 | + * @param int $form_id | |
| 907 | 922 | * |
| 908 | 923 | * @return array |
| 909 | 924 | */ |
| 910 | 925 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |