| @@ -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,9 +80,9 @@ | ||
| 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 | 86 | * @return array|bool |
| 80 | 87 | */ |
| 81 | 88 | public static function include_new_field( $field_type, $form_id ) { |
| @@ -80,8 +87,11 @@ | ||
| 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 ); |
| 83 | 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 | + | |
| 84 | 94 | /** |
| 85 | 95 | * @param array $field_values |
| 86 | 96 | */ |
| 87 | 97 | $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
| @@ -139,11 +149,11 @@ | ||
| 139 | 149 | |
| 140 | 150 | /** |
| 141 | 151 | * @since 3.0 |
| 142 | 152 | * |
| 143 | - * @param int|array|object $field_object | |
| 144 | - * @param array $values | |
| 145 | - * @param int $form_id | |
| 153 | + * @param array|int|object $field_object | |
| 154 | + * @param array $values | |
| 155 | + * @param int $form_id | |
| 146 | 156 | */ |
| 147 | 157 | public static function load_single_field( $field_object, $values, $form_id = 0 ) { |
| 148 | 158 | global $frm_vars; |
| 149 | 159 | $frm_vars['is_admin'] = true; |
| @@ -157,26 +167,26 @@ | ||
| 157 | 167 | |
| 158 | 168 | $field_obj = FrmFieldFactory::get_field_factory( $field_object ); |
| 159 | 169 | $display = self::display_field_options( array(), $field_obj ); |
| 160 | 170 | |
| 161 | - $ajax_loading = isset( $values['ajax_load'] ) && $values['ajax_load']; | |
| 162 | - $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 ); | |
| 163 | 173 | |
| 164 | 174 | if ( $ajax_loading && $ajax_this_field ) { |
| 165 | 175 | $li_classes = self::get_classes_for_builder_field( array(), $display, $field_obj ); |
| 166 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/ajax-field-placeholder.php' ); | |
| 167 | - } else { | |
| 168 | - if ( ! isset( $field ) && is_object( $field_object ) ) { | |
| 169 | - $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 | + } | |
| 170 | 179 | |
| 171 | - $field = FrmFieldsHelper::setup_edit_vars( $field_object ); | |
| 172 | - } | |
| 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 | + } | |
| 173 | 184 | |
| 174 | - $li_classes = self::get_classes_for_builder_field( $field, $display, $field_obj ); | |
| 175 | - $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'; | |
| 176 | 187 | |
| 177 | - require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); | |
| 178 | - } | |
| 188 | + require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php'; | |
| 179 | 189 | } |
| 180 | 190 | |
| 181 | 191 | /** |
| 182 | 192 | * @since 3.0 |
| @@ -206,10 +216,11 @@ | ||
| 206 | 216 | FrmField::destroy( $field_id ); |
| 207 | 217 | wp_die(); |
| 208 | 218 | } |
| 209 | 219 | |
| 210 | - /* Field Options */ | |
| 211 | - | |
| 220 | + /** | |
| 221 | + * Field Options. | |
| 222 | + */ | |
| 212 | 223 | public static function import_options() { |
| 213 | 224 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 214 | 225 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 215 | 226 | |
| @@ -216,12 +227,23 @@ | ||
| 216 | 227 | if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 217 | 228 | return; |
| 218 | 229 | } |
| 219 | 230 | |
| 220 | - $field_id = FrmAppHelper::get_param( 'field_id', '', 'post', 'absint' ); | |
| 221 | - $field = FrmField::getOne( $field_id ); | |
| 231 | + $field_id = FrmAppHelper::get_param( 'field_id', '', 'post', 'absint' ); | |
| 232 | + $field = FrmField::getOne( $field_id ); | |
| 233 | + $bulk_edit_types = array( 'radio', 'checkbox', 'select' ); | |
| 222 | 234 | |
| 223 | - if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { | |
| 235 | + /** | |
| 236 | + * Filter to add new fields that will support import_options/Bulk Edit Options. | |
| 237 | + * | |
| 238 | + * @since 6.8.4 | |
| 239 | + * | |
| 240 | + * @param array $bulk_edit_types | |
| 241 | + * @return array | |
| 242 | + */ | |
| 243 | + $bulk_edit_types = apply_filters( 'frm_bulk_edit_field_types', $bulk_edit_types ); | |
| 244 | + | |
| 245 | + if ( ! in_array( $field->type, $bulk_edit_types, true ) ) { | |
| 224 | 246 | return; |
| 225 | 247 | } |
| 226 | 248 | |
| 227 | 249 | $field = FrmFieldsHelper::setup_edit_vars( $field ); |
| @@ -228,15 +250,15 @@ | ||
| 228 | 250 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 229 | 251 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 230 | 252 | $opts = array_map( 'trim', $opts ); |
| 231 | 253 | |
| 232 | - $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' ); | |
| 254 | + $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' ); | |
| 233 | 255 | $field['separate_value'] = ( $separate === 'true' ); |
| 234 | 256 | |
| 235 | 257 | if ( $field['separate_value'] ) { |
| 236 | 258 | foreach ( $opts as $opt_key => $opt ) { |
| 237 | 259 | if ( strpos( $opt, '|' ) !== false ) { |
| 238 | - $vals = explode( '|', $opt ); | |
| 260 | + $vals = explode( '|', $opt ); | |
| 239 | 261 | $opts[ $opt_key ] = array( |
| 240 | 262 | 'label' => trim( $vals[0] ), |
| 241 | 263 | 'value' => trim( $vals[1] ), |
| 242 | 264 | ); |
| @@ -286,13 +308,13 @@ | ||
| 286 | 308 | if ( ! isset( $field['read_only'] ) ) { |
| 287 | 309 | $field['read_only'] = false; |
| 288 | 310 | } |
| 289 | 311 | |
| 290 | - $field_types = FrmFieldsHelper::get_field_types( $field['type'] ); | |
| 291 | - $pro_field_selection = FrmField::pro_field_selection(); | |
| 292 | - $all_field_types = array_merge( $pro_field_selection, FrmField::field_selection() ); | |
| 293 | - $disabled_fields = FrmAppHelper::pro_is_installed() ? array() : $pro_field_selection; | |
| 294 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 312 | + $field_selection_data = self::maybe_define_field_selection_data(); | |
| 313 | + $all_field_types = $field_selection_data->all_field_types; | |
| 314 | + $disabled_fields = $field_selection_data->disabled_fields; | |
| 315 | + $frm_settings = FrmAppHelper::get_settings(); | |
| 316 | + $field_types = FrmFieldTypeOptionData::get_field_types( $field['type'] ); | |
| 295 | 317 | |
| 296 | 318 | if ( ! isset( $all_field_types[ $field['type'] ] ) ) { |
| 297 | 319 | // Add fallback for an add-on field type that has been deactivated. |
| 298 | 320 | $all_field_types[ $field['type'] ] = array( |
| @@ -320,16 +342,31 @@ | ||
| 320 | 342 | include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php'; |
| 321 | 343 | } |
| 322 | 344 | |
| 323 | 345 | /** |
| 346 | + * @since 6.9.1 | |
| 347 | + * | |
| 348 | + * @return FrmFieldSelectionData | |
| 349 | + */ | |
| 350 | + private static function maybe_define_field_selection_data() { | |
| 351 | + if ( ! isset( self::$field_selection_data ) ) { | |
| 352 | + self::$field_selection_data = new FrmFieldSelectionData(); | |
| 353 | + } | |
| 354 | + return self::$field_selection_data; | |
| 355 | + } | |
| 356 | + | |
| 357 | + /** | |
| 324 | 358 | * Get the list of default value types that can be toggled in the builder. |
| 325 | 359 | * |
| 326 | 360 | * @since 4.0 |
| 361 | + * | |
| 362 | + * @param array $field | |
| 363 | + * @param array $atts | |
| 327 | 364 | * @return array |
| 328 | 365 | */ |
| 329 | 366 | private static function default_value_types( $field, $atts ) { |
| 330 | 367 | $types = array( |
| 331 | - 'default_value' => array( | |
| 368 | + 'default_value' => array( | |
| 332 | 369 | 'class' => '', |
| 333 | 370 | 'icon' => 'frm_icon_font frm_text2_icon', |
| 334 | 371 | 'title' => __( 'Default Value (Text)', 'formidable' ), |
| 335 | 372 | 'data' => array( |
| @@ -335,9 +372,9 @@ | ||
| 335 | 372 | 'data' => array( |
| 336 | 373 | 'frmshow' => '#default-value-for-', |
| 337 | 374 | ), |
| 338 | 375 | ), |
| 339 | - 'calc' => array( | |
| 376 | + 'calc' => array( | |
| 340 | 377 | 'class' => 'frm_show_upgrade frm_noallow', |
| 341 | 378 | 'title' => __( 'Default Value (Calculation)', 'formidable' ), |
| 342 | 379 | 'icon' => 'frm_icon_font frm_calculator_icon', |
| 343 | 380 | 'data' => array( |
| @@ -357,13 +394,8 @@ | ||
| 357 | 394 | ); |
| 358 | 395 | |
| 359 | 396 | $types = apply_filters( 'frm_default_value_types', $types, $atts ); |
| 360 | 397 | |
| 361 | - if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) { | |
| 362 | - // Prevent settings from showing in 2 spots. | |
| 363 | - unset( $types['calc'], $types['get_values_field'] ); | |
| 364 | - } | |
| 365 | - | |
| 366 | 398 | // Set active class. |
| 367 | 399 | $settings = array_keys( $types ); |
| 368 | 400 | $active = 'default_value'; |
| 369 | 401 | |
| @@ -404,9 +436,9 @@ | ||
| 404 | 436 | return $type; |
| 405 | 437 | } |
| 406 | 438 | |
| 407 | 439 | /** |
| 408 | - * @param array $settings | |
| 440 | + * @param array $settings | |
| 409 | 441 | * @param object $field_info |
| 410 | 442 | * |
| 411 | 443 | * @return array |
| 412 | 444 | */ |
| @@ -426,9 +458,17 @@ | ||
| 426 | 458 | * |
| 427 | 459 | * @param array $field |
| 428 | 460 | */ |
| 429 | 461 | public static function show_format_option( $field ) { |
| 430 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' ); | |
| 462 | + $attributes = array(); | |
| 463 | + $attributes['class'] = 'frm-has-modal'; | |
| 464 | + | |
| 465 | + if ( 'phone' === $field['type'] ) { | |
| 466 | + $attributes['id'] = 'frm-phone-field-custom-format-' . $field['id']; | |
| 467 | + $attributes['class'] .= ' frm_hidden'; | |
| 468 | + } | |
| 469 | + | |
| 470 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php'; | |
| 431 | 471 | } |
| 432 | 472 | |
| 433 | 473 | public static function input_html( $field, $echo = true ) { |
| 434 | 474 | $class = array(); |
| @@ -457,13 +497,13 @@ | ||
| 457 | 497 | return $add_html; |
| 458 | 498 | } |
| 459 | 499 | |
| 460 | 500 | private static function add_input_classes( $field, array &$class ) { |
| 461 | - if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { | |
| 501 | + if ( ! empty( $field['input_class'] ) ) { | |
| 462 | 502 | $class[] = $field['input_class']; |
| 463 | 503 | } |
| 464 | 504 | |
| 465 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { | |
| 505 | + if ( $field['type'] === 'hidden' || $field['type'] === 'user_id' ) { | |
| 466 | 506 | return; |
| 467 | 507 | } |
| 468 | 508 | |
| 469 | 509 | if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
| @@ -480,9 +520,9 @@ | ||
| 480 | 520 | 'file', |
| 481 | 521 | 'lookup', |
| 482 | 522 | ); |
| 483 | 523 | |
| 484 | - if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], $size_fields ) ) { | |
| 524 | + if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], $size_fields, true ) ) { | |
| 485 | 525 | return; |
| 486 | 526 | } |
| 487 | 527 | |
| 488 | 528 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| @@ -533,9 +573,9 @@ | ||
| 533 | 573 | 'hidden', |
| 534 | 574 | 'file', |
| 535 | 575 | ); |
| 536 | 576 | |
| 537 | - if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], $fields ) ) { | |
| 577 | + if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], $fields, true ) ) { | |
| 538 | 578 | return; |
| 539 | 579 | } |
| 540 | 580 | |
| 541 | 581 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| @@ -617,14 +657,31 @@ | ||
| 617 | 657 | if ( empty( $placeholder ) ) { |
| 618 | 658 | $placeholder = self::get_default_value_from_name( $field ); |
| 619 | 659 | } |
| 620 | 660 | |
| 661 | + $use_placeholder = $placeholder; | |
| 662 | + $autocomplete = FrmField::get_option( $field, 'autocom' ); | |
| 663 | + | |
| 664 | + if ( $autocomplete ) { | |
| 665 | + $use_chosen = ! is_callable( 'FrmProAppHelper::use_chosen_js' ) || FrmProAppHelper::use_chosen_js(); | |
| 666 | + if ( $use_chosen ) { | |
| 667 | + $use_placeholder = ''; | |
| 668 | + } | |
| 669 | + } | |
| 670 | + | |
| 621 | 671 | if ( $placeholder !== '' ) { |
| 622 | - ?> | |
| 623 | - <option value=""> | |
| 624 | - <?php echo esc_html( FrmField::get_option( $field, 'autocom' ) ? '' : $placeholder ); ?> | |
| 625 | - </option> | |
| 626 | - <?php | |
| 672 | + $placeholder_attributes = array( | |
| 673 | + 'class' => 'frm-select-placeholder', | |
| 674 | + 'value' => '', | |
| 675 | + 'data-placeholder' => 'true', | |
| 676 | + ); | |
| 677 | + | |
| 678 | + if ( $autocomplete && empty( $use_chosen ) ) { | |
| 679 | + // This is required for Slim Select. | |
| 680 | + $placeholder_attributes['data-placeholder'] = 'true'; | |
| 681 | + } | |
| 682 | + | |
| 683 | + FrmHtmlHelper::echo_dropdown_option( $use_placeholder, false, $placeholder_attributes ); | |
| 627 | 684 | return true; |
| 628 | 685 | } |
| 629 | 686 | |
| 630 | 687 | return false; |
| @@ -656,15 +713,17 @@ | ||
| 656 | 713 | } |
| 657 | 714 | } |
| 658 | 715 | |
| 659 | 716 | private static function add_validation_messages( $field, array &$add_html ) { |
| 660 | - if ( FrmField::is_required( $field ) ) { | |
| 717 | + $field_validation_messages_status = self::get_validation_data_attribute_visibility_info( $field ); | |
| 718 | + | |
| 719 | + if ( FrmField::is_required( $field ) && ! empty( $field_validation_messages_status['data-reqmsg'] ) ) { | |
| 661 | 720 | $required_message = FrmFieldsHelper::get_error_msg( $field, 'blank' ); |
| 662 | 721 | $add_html['data-reqmsg'] = 'data-reqmsg="' . esc_attr( $required_message ) . '"'; |
| 663 | 722 | self::maybe_add_html_required( $field, $add_html ); |
| 664 | 723 | } |
| 665 | 724 | |
| 666 | - if ( ! FrmField::is_option_empty( $field, 'invalid' ) ) { | |
| 725 | + if ( ! FrmField::is_option_empty( $field, 'invalid' ) && ! empty( $field_validation_messages_status['data-invmsg'] ) ) { | |
| 667 | 726 | $invalid_message = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 668 | 727 | $add_html['data-invmsg'] = 'data-invmsg="' . esc_attr( $invalid_message ) . '"'; |
| 669 | 728 | } |
| 670 | 729 | |
| @@ -673,8 +732,40 @@ | ||
| 673 | 732 | } |
| 674 | 733 | } |
| 675 | 734 | |
| 676 | 735 | /** |
| 736 | + * Returns an array that contains field validation messages status. | |
| 737 | + * | |
| 738 | + * @since 6.9 | |
| 739 | + * | |
| 740 | + * @param array|object $field | |
| 741 | + * @return array | |
| 742 | + */ | |
| 743 | + private static function get_validation_data_attribute_visibility_info( $field ) { | |
| 744 | + if ( FrmField::get_field_type( $field ) === 'hidden' ) { | |
| 745 | + $field_validation_data_attributes = array( | |
| 746 | + 'data-invmsg' => false, | |
| 747 | + 'data-reqmsg' => false, | |
| 748 | + ); | |
| 749 | + } else { | |
| 750 | + $field_validation_data_attributes = array( | |
| 751 | + 'data-invmsg' => true, | |
| 752 | + 'data-reqmsg' => true, | |
| 753 | + ); | |
| 754 | + } | |
| 755 | + | |
| 756 | + /** | |
| 757 | + * Allows controlling which field validation messages would be included in the field html. | |
| 758 | + * | |
| 759 | + * @since 6.9 | |
| 760 | + * | |
| 761 | + * @param array $field_validation_messages_status | |
| 762 | + * @param array|object $field | |
| 763 | + */ | |
| 764 | + return apply_filters( 'frm_field_validation_include_data_attributes', $field_validation_data_attributes, $field ); | |
| 765 | + } | |
| 766 | + | |
| 767 | + /** | |
| 677 | 768 | * @since 5.0.03 |
| 678 | 769 | * |
| 679 | 770 | * @param array $field |
| 680 | 771 | * @param array $add_html |
| @@ -695,9 +786,9 @@ | ||
| 695 | 786 | /** |
| 696 | 787 | * @since 5.0.03 |
| 697 | 788 | * |
| 698 | 789 | * @param array $field |
| 699 | - * @return stdClass|false false if there is no form object found with JS validation active. | |
| 790 | + * @return false|stdClass false if there is no form object found with JS validation active. | |
| 700 | 791 | */ |
| 701 | 792 | private static function get_form_for_js_validation( $field ) { |
| 702 | 793 | global $frm_vars; |
| 703 | 794 | if ( ! empty( $frm_vars['js_validate_forms'] ) ) { |
| @@ -714,9 +805,9 @@ | ||
| 714 | 805 | /** |
| 715 | 806 | * @param stdClass $form |
| 716 | 807 | * @param array $field |
| 717 | 808 | * @param array $errors |
| 718 | - * @return string|false | |
| 809 | + * @return false|string | |
| 719 | 810 | */ |
| 720 | 811 | public static function pull_custom_error_body_from_custom_html( $form, $field, $errors = array() ) { |
| 721 | 812 | if ( empty( $field['custom_html'] ) ) { |
| 722 | 813 | return false; |
| @@ -770,12 +861,9 @@ | ||
| 770 | 861 | if ( $excluded_field_types ) { |
| 771 | 862 | return; |
| 772 | 863 | } |
| 773 | 864 | |
| 774 | - $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' ); | |
| 775 | - if ( $include_html ) { | |
| 776 | - $add_html['aria-required'] = 'aria-required="true"'; | |
| 777 | - } | |
| 865 | + $add_html['aria-required'] = 'aria-required="true"'; | |
| 778 | 866 | } |
| 779 | 867 | |
| 780 | 868 | private static function add_shortcodes_to_html( $field, array &$add_html ) { |
| 781 | 869 | if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
| @@ -814,9 +902,9 @@ | ||
| 814 | 902 | private static function add_pattern_attribute( $field, array &$add_html ) { |
| 815 | 903 | $has_format = FrmField::is_option_true_in_array( $field, 'format' ); |
| 816 | 904 | $format_field = FrmField::is_field_type( $field, 'text' ); |
| 817 | 905 | |
| 818 | - if ( $field['type'] == 'phone' || ( $has_format && $format_field ) ) { | |
| 906 | + if ( $field['type'] === 'phone' || ( $has_format && $format_field ) ) { | |
| 819 | 907 | $frm_settings = FrmAppHelper::get_settings(); |
| 820 | 908 | |
| 821 | 909 | if ( $frm_settings->use_html ) { |
| 822 | 910 | $format = FrmEntryValidate::phone_format( $field ); |
| @@ -844,84 +932,6 @@ | ||
| 844 | 932 | $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
| 845 | 933 | } |
| 846 | 934 | |
| 847 | 935 | return $opt; |
| 848 | - } | |
| 849 | - | |
| 850 | - /** | |
| 851 | - * @deprecated 4.0 | |
| 852 | - */ | |
| 853 | - public static function update_ajax_option() { | |
| 854 | - _deprecated_function( __METHOD__, '4.0' ); | |
| 855 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); | |
| 856 | - check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 857 | - | |
| 858 | - $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); | |
| 859 | - if ( ! $field_id ) { | |
| 860 | - wp_die(); | |
| 861 | - } | |
| 862 | - | |
| 863 | - $field = FrmField::getOne( $field_id ); | |
| 864 | - | |
| 865 | - if ( isset( $_POST['separate_value'] ) ) { | |
| 866 | - $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1; | |
| 867 | - | |
| 868 | - $field->field_options['separate_value'] = $new_val; | |
| 869 | - unset( $new_val ); | |
| 870 | - } | |
| 871 | - | |
| 872 | - FrmField::update( | |
| 873 | - $field_id, | |
| 874 | - array( | |
| 875 | - 'field_options' => $field->field_options, | |
| 876 | - 'form_id' => $field->form_id, | |
| 877 | - ) | |
| 878 | - ); | |
| 879 | - wp_die(); | |
| 880 | - } | |
| 881 | - | |
| 882 | - /** | |
| 883 | - * @deprecated 4.0 | |
| 884 | - */ | |
| 885 | - public static function import_choices() { | |
| 886 | - _deprecated_function( __METHOD__, '4.0' ); | |
| 887 | - wp_die(); | |
| 888 | - } | |
| 889 | - | |
| 890 | - /** | |
| 891 | - * Add Single Option or Other Option. | |
| 892 | - * | |
| 893 | - * @deprecated 4.0 Moved to Pro for Other option only. | |
| 894 | - */ | |
| 895 | - public static function add_option() { | |
| 896 | - _deprecated_function( __METHOD__, '4.0', 'FrmProFieldsController::add_other_option' ); | |
| 897 | - } | |
| 898 | - | |
| 899 | - /** | |
| 900 | - * @deprecated 4.0 | |
| 901 | - */ | |
| 902 | - public static function update_order() { | |
| 903 | - FrmDeprecated::update_order(); | |
| 904 | - } | |
| 905 | - | |
| 906 | - /** | |
| 907 | - * @deprecated 3.0 | |
| 908 | - * @codeCoverageIgnore | |
| 909 | - */ | |
| 910 | - public static function edit_name( $field = 'name', $id = '' ) { | |
| 911 | - FrmDeprecated::edit_name( $field, $id ); | |
| 912 | - } | |
| 913 | - | |
| 914 | - /** | |
| 915 | - * @deprecated 3.0 | |
| 916 | - * @codeCoverageIgnore | |
| 917 | - * | |
| 918 | - * @param int $field_id | |
| 919 | - * @param array $values | |
| 920 | - * @param int $form_id | |
| 921 | - * | |
| 922 | - * @return array | |
| 923 | - */ | |
| 924 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { | |
| 925 | - return FrmDeprecated::include_single_field( $field_id, $values, $form_id ); | |
| 926 | 936 | } |
| 927 | 937 | } |