| @@ -63,15 +63,14 @@ | ||
| 63 | 63 | public static function create() { |
| 64 | 64 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 65 | 65 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 66 | 66 | |
| 67 | - $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); | |
| 68 | - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); | |
| 69 | - $field_options = FrmAppHelper::get_post_param( 'field_options', array(), 'wp_kses_post' ); | |
| 67 | + $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); | |
| 68 | + $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); | |
| 70 | 69 | |
| 71 | 70 | do_action( 'frm_before_create_field', $field_type, $form_id ); |
| 72 | 71 | |
| 73 | - $field = self::include_new_field( $field_type, $form_id, $field_options ); | |
| 72 | + $field = self::include_new_field( $field_type, $form_id ); | |
| 74 | 73 | |
| 75 | 74 | // this hook will allow for multiple fields to be added at once |
| 76 | 75 | do_action( 'frm_after_field_created', $field, $form_id ); |
| 77 | 76 | |
| @@ -82,19 +81,14 @@ | ||
| 82 | 81 | * Set up and create a new field |
| 83 | 82 | * |
| 84 | 83 | * @param string $field_type |
| 85 | 84 | * @param int $form_id |
| 86 | - * @param array $field_options | |
| 87 | 85 | * |
| 88 | 86 | * @return array|false |
| 89 | 87 | */ |
| 90 | - public static function include_new_field( $field_type, $form_id, $field_options = array() ) { | |
| 88 | + public static function include_new_field( $field_type, $form_id ) { | |
| 91 | 89 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 92 | 90 | |
| 93 | - if ( ! empty( $field_options ) ) { | |
| 94 | - $field_values['field_options'] = array_merge( $field_values['field_options'], $field_options ); | |
| 95 | - } | |
| 96 | - | |
| 97 | 91 | // When a new field is added to the form, flag it as draft and hide it from the front-end. |
| 98 | 92 | $field_values['field_options']['draft'] = 1; |
| 99 | 93 | |
| 100 | 94 | /** |
| @@ -183,23 +177,12 @@ | ||
| 183 | 177 | return; |
| 184 | 178 | } |
| 185 | 179 | |
| 186 | 180 | if ( ! isset( $field ) && is_object( $field_object ) ) { |
| 187 | - $field_object->parent_form_id = $values['id'] ?? $field_object->form_id; | |
| 181 | + $field_object->parent_form_id = isset( $values['id'] ) ? $values['id'] : $field_object->form_id; | |
| 188 | 182 | $field = FrmFieldsHelper::setup_edit_vars( $field_object ); |
| 189 | 183 | } |
| 190 | 184 | |
| 191 | - /** | |
| 192 | - * Filter for adding extra attributes to the field container. | |
| 193 | - * | |
| 194 | - * @since 6.23 | |
| 195 | - * | |
| 196 | - * @param array $extra_field_attributes | |
| 197 | - * @param array $field | |
| 198 | - * @param array $display | |
| 199 | - */ | |
| 200 | - $extra_field_attributes = apply_filters( 'frm_field_container_extra_attributes', array(), $field, $display ); | |
| 201 | - | |
| 202 | 185 | $li_classes = self::get_classes_for_builder_field( $field, $display, $field_obj ); |
| 203 | 186 | $li_classes .= ' ui-state-default widgets-holder-wrap'; |
| 204 | 187 | |
| 205 | 188 | require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php'; |
| @@ -390,32 +373,30 @@ | ||
| 390 | 373 | $types = array( |
| 391 | 374 | 'default_value' => array( |
| 392 | 375 | 'class' => '', |
| 393 | 376 | 'icon' => 'frm_icon_font frm_text2_icon', |
| 394 | - 'title' => __( 'Default Value', 'formidable' ), | |
| 377 | + 'title' => __( 'Default Value (Text)', 'formidable' ), | |
| 395 | 378 | 'data' => array( |
| 396 | 379 | 'frmshow' => '#default-value-for-', |
| 397 | 380 | ), |
| 398 | 381 | ), |
| 399 | 382 | 'calc' => array( |
| 400 | - 'class' => 'frm_show_upgrade frm_noallow', | |
| 401 | - 'title' => __( 'Calculate Value', 'formidable' ), | |
| 402 | - 'icon' => 'frm_icon_font frm_calculator_icon', | |
| 403 | - 'data' => array( | |
| 383 | + 'class' => 'frm_show_upgrade frm_noallow', | |
| 384 | + 'title' => __( 'Default Value (Calculation)', 'formidable' ), | |
| 385 | + 'icon' => 'frm_icon_font frm_calculator_icon', | |
| 386 | + 'data' => array( | |
| 404 | 387 | 'medium' => 'calculations', |
| 405 | 388 | 'upgrade' => __( 'Calculator forms', 'formidable' ), |
| 406 | 389 | ), |
| 407 | - 'tooltip' => __( 'Automatically calculate the value of this field based on values from other fields.', 'formidable' ), | |
| 408 | 390 | ), |
| 409 | 391 | 'get_values_field' => array( |
| 410 | - 'class' => 'frm_show_upgrade frm_noallow', | |
| 411 | - 'title' => __( 'Lookup', 'formidable' ), | |
| 412 | - 'icon' => 'frm_icon_font frm_search_icon', | |
| 413 | - 'data' => array( | |
| 392 | + 'class' => 'frm_show_upgrade frm_noallow', | |
| 393 | + 'title' => __( 'Default Value (Lookup)', 'formidable' ), | |
| 394 | + 'icon' => 'frm_icon_font frm_search_icon', | |
| 395 | + 'data' => array( | |
| 414 | 396 | 'medium' => 'lookup', |
| 415 | 397 | 'upgrade' => __( 'Lookup fields', 'formidable' ), |
| 416 | 398 | ), |
| 417 | - 'tooltip' => __( 'Dynamically retrieve the value of this field from a lookup field.', 'formidable' ), | |
| 418 | 399 | ), |
| 419 | 400 | ); |
| 420 | 401 | |
| 421 | 402 | $types = apply_filters( 'frm_default_value_types', $types, $atts ); |
| @@ -423,13 +404,11 @@ | ||
| 423 | 404 | // Set active class. |
| 424 | 405 | $settings = array_keys( $types ); |
| 425 | 406 | $active = 'default_value'; |
| 426 | 407 | |
| 427 | - if ( FrmAppHelper::pro_is_connected() ) { | |
| 428 | - foreach ( $settings as $type ) { | |
| 429 | - if ( ! empty( $field[ $type ] ) ) { | |
| 430 | - $active = $type; | |
| 431 | - } | |
| 408 | + foreach ( $settings as $type ) { | |
| 409 | + if ( ! empty( $field[ $type ] ) ) { | |
| 410 | + $active = $type; | |
| 432 | 411 | } |
| 433 | 412 | } |
| 434 | 413 | |
| 435 | 414 | $types[ $active ]['class'] .= ' current'; |
| @@ -674,9 +653,9 @@ | ||
| 674 | 653 | * @param array $field Field array. |
| 675 | 654 | * @return string |
| 676 | 655 | */ |
| 677 | 656 | private static function prepare_placeholder( $field ) { |
| 678 | - $placeholder = $field['placeholder'] ?? ''; | |
| 657 | + $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; | |
| 679 | 658 | |
| 680 | 659 | return $placeholder; |
| 681 | 660 | } |
| 682 | 661 | |
| @@ -998,11 +977,11 @@ | ||
| 998 | 977 | |
| 999 | 978 | public static function check_value( $opt, $opt_key, $field ) { |
| 1000 | 979 | if ( is_array( $opt ) ) { |
| 1001 | 980 | if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
| 1002 | - $opt = $opt['value'] ?? $opt['label'] ?? reset( $opt ); | |
| 981 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); | |
| 1003 | 982 | } else { |
| 1004 | - $opt = $opt['label'] ?? reset( $opt ); | |
| 983 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); | |
| 1005 | 984 | } |
| 1006 | 985 | } |
| 1007 | 986 | |
| 1008 | 987 | return $opt; |
| @@ -1009,9 +988,9 @@ | ||
| 1009 | 988 | } |
| 1010 | 989 | |
| 1011 | 990 | public static function check_label( $opt ) { |
| 1012 | 991 | if ( is_array( $opt ) ) { |
| 1013 | - $opt = $opt['label'] ?? reset( $opt ); | |
| 992 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); | |
| 1014 | 993 | } |
| 1015 | 994 | |
| 1016 | 995 | return $opt; |
| 1017 | 996 | } |