Completed
Push — master ( b7e0e9...860ff9 )
by Stephanie
02:52
created
classes/controllers/FrmFieldsController.php 1 patch
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17 17
 		$values = array(
18 18
 			'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
19 19
 			'doing_ajax' => true,
20 20
 		);
21
-        $field_html = array();
21
+		$field_html = array();
22 22
 
23
-        foreach ( $fields as $field ) {
23
+		foreach ( $fields as $field ) {
24 24
 			$field = htmlspecialchars_decode( nl2br( $field ) );
25 25
 			$field = json_decode( $field );
26 26
 			if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) {
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 			self::load_single_field( $field, $values );
40 40
 			$field_html[ absint( $field->id ) ] = ob_get_contents();
41 41
 			ob_end_clean();
42
-        }
42
+		}
43 43
 
44 44
 		echo json_encode( $field_html );
45 45
 
46
-        wp_die();
47
-    }
46
+		wp_die();
47
+	}
48 48
 
49 49
 	/**
50 50
 	 * Create a new field with ajax
51 51
 	 */
52
-    public static function create() {
52
+	public static function create() {
53 53
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
54
-        check_ajax_referer( 'frm_ajax', 'nonce' );
54
+		check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
@@ -61,25 +61,25 @@  discard block
 block discarded – undo
61 61
 		// this hook will allow for multiple fields to be added at once
62 62
 		do_action( 'frm_after_field_created', $field, $form_id );
63 63
 
64
-        wp_die();
65
-    }
64
+		wp_die();
65
+	}
66 66
 
67
-    /**
68
-     * Set up and create a new field
69
-     *
70
-     * @param string $field_type
71
-     * @param integer $form_id
72
-     * @return array|bool
73
-     */
67
+	/**
68
+	 * Set up and create a new field
69
+	 *
70
+	 * @param string $field_type
71
+	 * @param integer $form_id
72
+	 * @return array|bool
73
+	 */
74 74
 	public static function include_new_field( $field_type, $form_id ) {
75 75
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
76
-        $field_values = apply_filters( 'frm_before_field_created', $field_values );
76
+		$field_values = apply_filters( 'frm_before_field_created', $field_values );
77 77
 
78
-        $field_id = FrmField::create( $field_values );
78
+		$field_id = FrmField::create( $field_values );
79 79
 
80
-        if ( ! $field_id ) {
81
-            return false;
82
-        }
80
+		if ( ! $field_id ) {
81
+			return false;
82
+		}
83 83
 
84 84
 		$field = self::get_field_array_from_id( $field_id );
85 85
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 
96 96
 		self::load_single_field( $field, $values, $form_id );
97 97
 
98
-        return $field;
99
-    }
98
+		return $field;
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * @deprecated 3.0
@@ -112,29 +112,29 @@  discard block
 block discarded – undo
112 112
 			$field = 'name';
113 113
 		}
114 114
 
115
-        if ( empty( $id ) ) {
115
+		if ( empty( $id ) ) {
116 116
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
117 117
 			$id = str_replace( 'field_label_', '', $id );
118
-        }
118
+		}
119 119
 
120 120
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
121 121
 		$value = trim( $value );
122
-        if ( trim( strip_tags( $value ) ) === '' ) {
123
-            // set blank value if there is no content
124
-            $value = '';
125
-        }
122
+		if ( trim( strip_tags( $value ) ) === '' ) {
123
+			// set blank value if there is no content
124
+			$value = '';
125
+		}
126 126
 
127 127
 		FrmField::update( $id, array( $field => $value ) );
128 128
 
129 129
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
130 130
 
131 131
 		echo stripslashes( wp_kses_post( $value ) ); // WPCS: XSS ok.
132
-        wp_die();
133
-    }
132
+		wp_die();
133
+	}
134 134
 
135
-    public static function update_ajax_option() {
135
+	public static function update_ajax_option() {
136 136
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
137
-        check_ajax_referer( 'frm_ajax', 'nonce' );
137
+		check_ajax_referer( 'frm_ajax', 'nonce' );
138 138
 
139 139
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
140 140
 		if ( ! $field_id ) {
@@ -156,20 +156,20 @@  discard block
 block discarded – undo
156 156
 				'form_id'       => $field->form_id,
157 157
 			)
158 158
 		);
159
-        wp_die();
160
-    }
159
+		wp_die();
160
+	}
161 161
 
162
-    public static function duplicate() {
162
+	public static function duplicate() {
163 163
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
164
-        check_ajax_referer( 'frm_ajax', 'nonce' );
164
+		check_ajax_referer( 'frm_ajax', 'nonce' );
165 165
 
166 166
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
167 167
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
168 168
 
169 169
 		$copy_field = FrmField::getOne( $field_id );
170
-        if ( ! $copy_field ) {
171
-            wp_die( esc_html( __( 'No field found to duplicate:', 'formidable' ) . ' ' . $field_id ) );
172
-        }
170
+		if ( ! $copy_field ) {
171
+			wp_die( esc_html( __( 'No field found to duplicate:', 'formidable' ) . ' ' . $field_id ) );
172
+		}
173 173
 
174 174
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
175 175
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 			self::load_single_field( $field_id, $values );
186 186
 		}
187 187
 
188
-        wp_die();
189
-    }
188
+		wp_die();
189
+	}
190 190
 
191 191
 	/**
192 192
 	 * Load a single field in the form builder along with all needed variables
@@ -278,21 +278,21 @@  discard block
 block discarded – undo
278 278
 		return $li_classes;
279 279
 	}
280 280
 
281
-    public static function destroy() {
281
+	public static function destroy() {
282 282
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
283
-        check_ajax_referer( 'frm_ajax', 'nonce' );
283
+		check_ajax_referer( 'frm_ajax', 'nonce' );
284 284
 
285 285
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
286 286
 		FrmField::destroy( $field_id );
287
-        wp_die();
288
-    }
287
+		wp_die();
288
+	}
289 289
 
290
-    /* Field Options */
290
+	/* Field Options */
291 291
 
292
-    //Add Single Option or Other Option
293
-    public static function add_option() {
292
+	//Add Single Option or Other Option
293
+	public static function add_option() {
294 294
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
295
-        check_ajax_referer( 'frm_ajax', 'nonce' );
295
+		check_ajax_referer( 'frm_ajax', 'nonce' );
296 296
 
297 297
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
298 298
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
@@ -317,69 +317,69 @@  discard block
 block discarded – undo
317 317
 		FrmFieldsHelper::show_single_option( $field );
318 318
 
319 319
 		wp_die();
320
-    }
320
+	}
321 321
 
322 322
 	/**
323 323
 	 * @deprecated 2.3
324 324
 	 * @codeCoverageIgnore
325 325
 	 */
326
-    public static function edit_option() {
326
+	public static function edit_option() {
327 327
 		_deprecated_function( __FUNCTION__, '2.3' );
328
-    }
328
+	}
329 329
 
330 330
 	/**
331 331
 	 * @deprecated 2.3
332 332
 	 * @codeCoverageIgnore
333 333
 	 */
334
-    public static function delete_option() {
334
+	public static function delete_option() {
335 335
 		_deprecated_function( __FUNCTION__, '2.3' );
336
-    }
336
+	}
337 337
 
338
-    public static function import_choices() {
339
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
338
+	public static function import_choices() {
339
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
340 340
 
341 341
 		$field_id = absint( $_REQUEST['field_id'] );
342 342
 
343
-        global $current_screen, $hook_suffix;
343
+		global $current_screen, $hook_suffix;
344 344
 
345
-        // Catch plugins that include admin-header.php before admin.php completes.
346
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
347
-            $hook_suffix = '';
348
-        	set_current_screen();
349
-        }
345
+		// Catch plugins that include admin-header.php before admin.php completes.
346
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
347
+			$hook_suffix = '';
348
+			set_current_screen();
349
+		}
350 350
 
351
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
352
-            register_admin_color_schemes();
353
-        }
351
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
352
+			register_admin_color_schemes();
353
+		}
354 354
 
355 355
 		$hook_suffix = '';
356 356
 		$admin_body_class = '';
357 357
 
358
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
359
-        	$admin_body_class .= ' folded';
360
-        }
358
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
359
+			$admin_body_class .= ' folded';
360
+		}
361 361
 
362
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
363
-        	$admin_body_class .= ' admin-bar';
364
-        }
362
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
363
+			$admin_body_class .= ' admin-bar';
364
+		}
365 365
 
366
-        if ( is_rtl() ) {
367
-        	$admin_body_class .= ' rtl';
368
-        }
366
+		if ( is_rtl() ) {
367
+			$admin_body_class .= ' rtl';
368
+		}
369 369
 
370
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
371
-        $prepop = array();
370
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
371
+		$prepop = array();
372 372
 		FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
373 373
 
374 374
 		$field = FrmField::getOne( $field_id );
375 375
 
376
-        wp_enqueue_script( 'utils' );
376
+		wp_enqueue_script( 'utils' );
377 377
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
378
-        FrmAppHelper::load_admin_wide_js();
378
+		FrmAppHelper::load_admin_wide_js();
379 379
 
380 380
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
381
-        wp_die();
382
-    }
381
+		wp_die();
382
+	}
383 383
 
384 384
 	public static function import_options() {
385 385
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 		$field = FrmField::getOne( $field_id );
394 394
 
395 395
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
396
-            return;
397
-        }
396
+			return;
397
+		}
398 398
 
399 399
 		$field = FrmFieldsHelper::setup_edit_vars( $field );
400 400
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
@@ -417,10 +417,10 @@  discard block
 block discarded – undo
417 417
 			}
418 418
 		}
419 419
 
420
-        //Keep other options after bulk update
421
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
422
-            $other_array = array();
423
-            foreach ( $field['options'] as $opt_key => $opt ) {
420
+		//Keep other options after bulk update
421
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
422
+			$other_array = array();
423
+			foreach ( $field['options'] as $opt_key => $opt ) {
424 424
 				if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
425 425
 					$other_array[ $opt_key ] = $opt;
426 426
 				}
@@ -431,36 +431,36 @@  discard block
 block discarded – undo
431 431
 			}
432 432
 		}
433 433
 
434
-        $field['options'] = $opts;
434
+		$field['options'] = $opts;
435 435
 
436 436
 		FrmFieldsHelper::show_single_option( $field );
437 437
 
438
-        wp_die();
439
-    }
438
+		wp_die();
439
+	}
440 440
 
441
-    public static function update_order() {
441
+	public static function update_order() {
442 442
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
443
-        check_ajax_referer( 'frm_ajax', 'nonce' );
443
+		check_ajax_referer( 'frm_ajax', 'nonce' );
444 444
 
445 445
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
446 446
 		foreach ( (array) $fields as $position => $item ) {
447 447
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
448 448
 		}
449
-        wp_die();
450
-    }
449
+		wp_die();
450
+	}
451 451
 
452 452
 	public static function change_type( $type ) {
453
-        $type_switch = array(
454
-            'scale'     => 'radio',
453
+		$type_switch = array(
454
+			'scale'     => 'radio',
455 455
 			'star'      => 'radio',
456
-            '10radio'   => 'radio',
457
-            'rte'       => 'textarea',
458
-            'website'   => 'url',
456
+			'10radio'   => 'radio',
457
+			'rte'       => 'textarea',
458
+			'website'   => 'url',
459 459
 			'image'     => 'url',
460
-        );
461
-        if ( isset( $type_switch[ $type ] ) ) {
462
-            $type = $type_switch[ $type ];
463
-        }
460
+		);
461
+		if ( isset( $type_switch[ $type ] ) ) {
462
+			$type = $type_switch[ $type ];
463
+		}
464 464
 
465 465
 		$pro_fields = FrmField::pro_field_selection();
466 466
 		$types = array_keys( $pro_fields );
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 			$type = 'text';
469 469
 		}
470 470
 
471
-        return $type;
472
-    }
471
+		return $type;
472
+	}
473 473
 
474 474
 	/**
475 475
 	 * @param array $settings
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 		}
485 485
 
486 486
 		return apply_filters( 'frm_display_field_options', $settings );
487
-    }
487
+	}
488 488
 
489 489
 	/**
490 490
 	 * Display the format option
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' );
497 497
 	}
498 498
 
499
-    public static function input_html( $field, $echo = true ) {
500
-        $class = array(); //$field['type'];
499
+	public static function input_html( $field, $echo = true ) {
500
+		$class = array(); //$field['type'];
501 501
 		self::add_input_classes( $field, $class );
502 502
 
503 503
 		$add_html = array();
@@ -516,85 +516,85 @@  discard block
 block discarded – undo
516 516
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
517 517
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
518 518
 
519
-        if ( $echo ) {
520
-            echo $add_html; // WPCS: XSS ok.
521
-        }
519
+		if ( $echo ) {
520
+			echo $add_html; // WPCS: XSS ok.
521
+		}
522 522
 
523
-        return $add_html;
524
-    }
523
+		return $add_html;
524
+	}
525 525
 
526 526
 	private static function add_input_classes( $field, array &$class ) {
527 527
 		if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
528 528
 			$class[] = $field['input_class'];
529 529
 		}
530 530
 
531
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
532
-            return;
533
-        }
531
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
532
+			return;
533
+		}
534 534
 
535 535
 		if ( isset( $field['size'] ) && $field['size'] > 0 ) {
536 536
 			$class[] = 'auto_width';
537 537
 		}
538
-    }
538
+	}
539 539
 
540 540
 	private static function add_html_size( $field, array &$add_html ) {
541 541
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) {
542
-            return;
543
-        }
542
+			return;
543
+		}
544 544
 
545 545
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
546
-            return;
547
-        }
546
+			return;
547
+		}
548 548
 
549 549
 		if ( is_numeric( $field['size'] ) ) {
550 550
 			$field['size'] .= 'px';
551 551
 		}
552 552
 
553 553
 		$important = apply_filters( 'frm_use_important_width', 1, $field );
554
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
554
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
555 555
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
556 556
 
557 557
 		self::add_html_cols( $field, $add_html );
558
-    }
558
+	}
559 559
 
560 560
 	private static function add_html_cols( $field, array &$add_html ) {
561 561
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
562
-            return;
563
-        }
562
+			return;
563
+		}
564 564
 
565
-        // convert to cols for textareas
566
-        $calc = array(
567
-            ''      => 9,
568
-            'px'    => 9,
569
-            'rem'   => 0.444,
570
-            'em'    => 0.544,
571
-        );
565
+		// convert to cols for textareas
566
+		$calc = array(
567
+			''      => 9,
568
+			'px'    => 9,
569
+			'rem'   => 0.444,
570
+			'em'    => 0.544,
571
+		);
572 572
 
573 573
 		// include "col" for valid html
574 574
 		$unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
575 575
 
576
-        if ( ! isset( $calc[ $unit ] ) ) {
577
-            return;
578
-        }
576
+		if ( ! isset( $calc[ $unit ] ) ) {
577
+			return;
578
+		}
579 579
 
580
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
580
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
581 581
 
582 582
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
583
-    }
583
+	}
584 584
 
585 585
 	private static function add_html_length( $field, array &$add_html ) {
586
-        // check for max setting and if this field accepts maxlength
586
+		// check for max setting and if this field accepts maxlength
587 587
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) {
588
-            return;
589
-        }
588
+			return;
589
+		}
590 590
 
591 591
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
592
-            // don't load on form builder page
593
-            return;
594
-        }
592
+			// don't load on form builder page
593
+			return;
594
+		}
595 595
 
596 596
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
597
-    }
597
+	}
598 598
 
599 599
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
600 600
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -703,27 +703,27 @@  discard block
 block discarded – undo
703 703
 		}
704 704
 	}
705 705
 
706
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
707
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
708
-            return;
709
-        }
706
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
707
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
708
+			return;
709
+		}
710 710
 
711
-        foreach ( $field['shortcodes'] as $k => $v ) {
712
-            if ( 'opt' === $k ) {
713
-                continue;
714
-            }
711
+		foreach ( $field['shortcodes'] as $k => $v ) {
712
+			if ( 'opt' === $k ) {
713
+				continue;
714
+			}
715 715
 
716 716
 			if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
717
-                $add_html[] = $v;
718
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
717
+				$add_html[] = $v;
718
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
719 719
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
720
-            } else {
720
+			} else {
721 721
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
722
-            }
722
+			}
723 723
 
724 724
 			unset( $k, $v );
725
-        }
726
-    }
725
+		}
726
+	}
727 727
 
728 728
 	/**
729 729
 	 * Add pattern attribute
@@ -747,16 +747,16 @@  discard block
 block discarded – undo
747 747
 		}
748 748
 	}
749 749
 
750
-    public static function check_value( $opt, $opt_key, $field ) {
751
-        if ( is_array( $opt ) ) {
752
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
753
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
754
-            } else {
755
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
756
-            }
757
-        }
758
-        return $opt;
759
-    }
750
+	public static function check_value( $opt, $opt_key, $field ) {
751
+		if ( is_array( $opt ) ) {
752
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
753
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
754
+			} else {
755
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
756
+			}
757
+		}
758
+		return $opt;
759
+	}
760 760
 
761 761
 	public static function check_label( $opt ) {
762 762
 		if ( is_array( $opt ) ) {
Please login to merge, or discard this patch.