Completed
Push — master ( abd0cd...4ef3e4 )
by Stephanie
03:27
created
classes/controllers/FrmFieldsController.php 1 patch
Indentation   +179 added lines, -179 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 ) );
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 ) {
@@ -149,24 +149,24 @@  discard block
 block discarded – undo
149 149
 			unset( $new_val );
150 150
 		}
151 151
 
152
-        FrmField::update( $field_id, array(
153
-            'field_options' => $field->field_options,
152
+		FrmField::update( $field_id, array(
153
+			'field_options' => $field->field_options,
154 154
 			'form_id'       => $field->form_id,
155
-        ) );
156
-        wp_die();
157
-    }
155
+		) );
156
+		wp_die();
157
+	}
158 158
 
159
-    public static function duplicate() {
159
+	public static function duplicate() {
160 160
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
161
-        check_ajax_referer( 'frm_ajax', 'nonce' );
161
+		check_ajax_referer( 'frm_ajax', 'nonce' );
162 162
 
163 163
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
164 164
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
165 165
 
166 166
 		$copy_field = FrmField::getOne( $field_id );
167
-        if ( ! $copy_field ) {
168
-            wp_die();
169
-        }
167
+		if ( ! $copy_field ) {
168
+			wp_die();
169
+		}
170 170
 
171 171
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
172 172
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 			self::load_single_field( $field_id, $values );
181 181
 		}
182 182
 
183
-        wp_die();
184
-    }
183
+		wp_die();
184
+	}
185 185
 
186 186
 	/**
187 187
 	 * Load a single field in the form builder along with all needed variables
@@ -273,21 +273,21 @@  discard block
 block discarded – undo
273 273
 		return $li_classes;
274 274
 	}
275 275
 
276
-    public static function destroy() {
276
+	public static function destroy() {
277 277
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
278
-        check_ajax_referer( 'frm_ajax', 'nonce' );
278
+		check_ajax_referer( 'frm_ajax', 'nonce' );
279 279
 
280 280
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
281 281
 		FrmField::destroy( $field_id );
282
-        wp_die();
283
-    }
282
+		wp_die();
283
+	}
284 284
 
285
-    /* Field Options */
285
+	/* Field Options */
286 286
 
287
-    //Add Single Option or Other Option
288
-    public static function add_option() {
287
+	//Add Single Option or Other Option
288
+	public static function add_option() {
289 289
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
290
-        check_ajax_referer( 'frm_ajax', 'nonce' );
290
+		check_ajax_referer( 'frm_ajax', 'nonce' );
291 291
 
292 292
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
293 293
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
@@ -312,69 +312,69 @@  discard block
 block discarded – undo
312 312
 		FrmFieldsHelper::show_single_option( $field );
313 313
 
314 314
 		wp_die();
315
-    }
315
+	}
316 316
 
317 317
 	/**
318 318
 	 * @deprecated 2.3
319 319
 	 * @codeCoverageIgnore
320 320
 	 */
321
-    public static function edit_option() {
321
+	public static function edit_option() {
322 322
 		_deprecated_function( __FUNCTION__, '2.3' );
323
-    }
323
+	}
324 324
 
325 325
 	/**
326 326
 	 * @deprecated 2.3
327 327
 	 * @codeCoverageIgnore
328 328
 	 */
329
-    public static function delete_option() {
329
+	public static function delete_option() {
330 330
 		_deprecated_function( __FUNCTION__, '2.3' );
331
-    }
331
+	}
332 332
 
333
-    public static function import_choices() {
334
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
333
+	public static function import_choices() {
334
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
335 335
 
336 336
 		$field_id = absint( $_REQUEST['field_id'] );
337 337
 
338
-        global $current_screen, $hook_suffix;
338
+		global $current_screen, $hook_suffix;
339 339
 
340
-        // Catch plugins that include admin-header.php before admin.php completes.
341
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
342
-            $hook_suffix = '';
343
-        	set_current_screen();
344
-        }
340
+		// Catch plugins that include admin-header.php before admin.php completes.
341
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
342
+			$hook_suffix = '';
343
+			set_current_screen();
344
+		}
345 345
 
346
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
347
-            register_admin_color_schemes();
348
-        }
346
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
347
+			register_admin_color_schemes();
348
+		}
349 349
 
350 350
 		$hook_suffix = '';
351 351
 		$admin_body_class = '';
352 352
 
353
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
354
-        	$admin_body_class .= ' folded';
355
-        }
353
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
354
+			$admin_body_class .= ' folded';
355
+		}
356 356
 
357
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
358
-        	$admin_body_class .= ' admin-bar';
359
-        }
357
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
358
+			$admin_body_class .= ' admin-bar';
359
+		}
360 360
 
361
-        if ( is_rtl() ) {
362
-        	$admin_body_class .= ' rtl';
363
-        }
361
+		if ( is_rtl() ) {
362
+			$admin_body_class .= ' rtl';
363
+		}
364 364
 
365
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
366
-        $prepop = array();
365
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
366
+		$prepop = array();
367 367
 		FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
368 368
 
369 369
 		$field = FrmField::getOne( $field_id );
370 370
 
371
-        wp_enqueue_script( 'utils' );
371
+		wp_enqueue_script( 'utils' );
372 372
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
373
-        FrmAppHelper::load_admin_wide_js();
373
+		FrmAppHelper::load_admin_wide_js();
374 374
 
375 375
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
376
-        wp_die();
377
-    }
376
+		wp_die();
377
+	}
378 378
 
379 379
 	public static function import_options() {
380 380
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 		$field = FrmField::getOne( $field_id );
389 389
 
390 390
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
391
-            return;
392
-        }
391
+			return;
392
+		}
393 393
 
394 394
 		$field = FrmFieldsHelper::setup_edit_vars( $field );
395 395
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
 			}
413 413
 		}
414 414
 
415
-        //Keep other options after bulk update
416
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
417
-            $other_array = array();
418
-            foreach ( $field['options'] as $opt_key => $opt ) {
415
+		//Keep other options after bulk update
416
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
417
+			$other_array = array();
418
+			foreach ( $field['options'] as $opt_key => $opt ) {
419 419
 				if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
420 420
 					$other_array[ $opt_key ] = $opt;
421 421
 				}
@@ -426,36 +426,36 @@  discard block
 block discarded – undo
426 426
 			}
427 427
 		}
428 428
 
429
-        $field['options'] = $opts;
429
+		$field['options'] = $opts;
430 430
 
431 431
 		FrmFieldsHelper::show_single_option( $field );
432 432
 
433
-        wp_die();
434
-    }
433
+		wp_die();
434
+	}
435 435
 
436
-    public static function update_order() {
436
+	public static function update_order() {
437 437
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
438
-        check_ajax_referer( 'frm_ajax', 'nonce' );
438
+		check_ajax_referer( 'frm_ajax', 'nonce' );
439 439
 
440 440
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
441 441
 		foreach ( (array) $fields as $position => $item ) {
442 442
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
443 443
 		}
444
-        wp_die();
445
-    }
444
+		wp_die();
445
+	}
446 446
 
447 447
 	public static function change_type( $type ) {
448
-        $type_switch = array(
449
-            'scale'     => 'radio',
448
+		$type_switch = array(
449
+			'scale'     => 'radio',
450 450
 			'star'      => 'radio',
451
-            '10radio'   => 'radio',
452
-            'rte'       => 'textarea',
453
-            'website'   => 'url',
451
+			'10radio'   => 'radio',
452
+			'rte'       => 'textarea',
453
+			'website'   => 'url',
454 454
 			'image'     => 'url',
455
-        );
456
-        if ( isset( $type_switch[ $type ] ) ) {
457
-            $type = $type_switch[ $type ];
458
-        }
455
+		);
456
+		if ( isset( $type_switch[ $type ] ) ) {
457
+			$type = $type_switch[ $type ];
458
+		}
459 459
 
460 460
 		$pro_fields = FrmField::pro_field_selection();
461 461
 		$types = array_keys( $pro_fields );
@@ -463,8 +463,8 @@  discard block
 block discarded – undo
463 463
 			$type = 'text';
464 464
 		}
465 465
 
466
-        return $type;
467
-    }
466
+		return $type;
467
+	}
468 468
 
469 469
 	/**
470 470
 	 * @param array $settings
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 		}
480 480
 
481 481
 		return apply_filters( 'frm_display_field_options', $settings );
482
-    }
482
+	}
483 483
 
484 484
 	/**
485 485
 	 * Display the format option
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' );
492 492
 	}
493 493
 
494
-    public static function input_html( $field, $echo = true ) {
495
-        $class = array(); //$field['type'];
494
+	public static function input_html( $field, $echo = true ) {
495
+		$class = array(); //$field['type'];
496 496
 		self::add_input_classes( $field, $class );
497 497
 
498 498
 		$add_html = array();
@@ -511,85 +511,85 @@  discard block
 block discarded – undo
511 511
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
512 512
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
513 513
 
514
-        if ( $echo ) {
515
-            echo $add_html;
516
-        }
514
+		if ( $echo ) {
515
+			echo $add_html;
516
+		}
517 517
 
518
-        return $add_html;
519
-    }
518
+		return $add_html;
519
+	}
520 520
 
521 521
 	private static function add_input_classes( $field, array &$class ) {
522 522
 		if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
523 523
 			$class[] = $field['input_class'];
524 524
 		}
525 525
 
526
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
527
-            return;
528
-        }
526
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
527
+			return;
528
+		}
529 529
 
530 530
 		if ( isset( $field['size'] ) && $field['size'] > 0 ) {
531 531
 			$class[] = 'auto_width';
532 532
 		}
533
-    }
533
+	}
534 534
 
535 535
 	private static function add_html_size( $field, array &$add_html ) {
536 536
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) {
537
-            return;
538
-        }
537
+			return;
538
+		}
539 539
 
540 540
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
541
-            return;
542
-        }
541
+			return;
542
+		}
543 543
 
544 544
 		if ( is_numeric( $field['size'] ) ) {
545 545
 			$field['size'] .= 'px';
546 546
 		}
547 547
 
548 548
 		$important = apply_filters( 'frm_use_important_width', 1, $field );
549
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
549
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
550 550
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
551 551
 
552 552
 		self::add_html_cols( $field, $add_html );
553
-    }
553
+	}
554 554
 
555 555
 	private static function add_html_cols( $field, array &$add_html ) {
556 556
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
557
-            return;
558
-        }
557
+			return;
558
+		}
559 559
 
560
-        // convert to cols for textareas
561
-        $calc = array(
562
-            ''      => 9,
563
-            'px'    => 9,
564
-            'rem'   => 0.444,
565
-            'em'    => 0.544,
566
-        );
560
+		// convert to cols for textareas
561
+		$calc = array(
562
+			''      => 9,
563
+			'px'    => 9,
564
+			'rem'   => 0.444,
565
+			'em'    => 0.544,
566
+		);
567 567
 
568 568
 		// include "col" for valid html
569 569
 		$unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
570 570
 
571
-        if ( ! isset( $calc[ $unit ] ) ) {
572
-            return;
573
-        }
571
+		if ( ! isset( $calc[ $unit ] ) ) {
572
+			return;
573
+		}
574 574
 
575
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
575
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
576 576
 
577 577
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
578
-    }
578
+	}
579 579
 
580 580
 	private static function add_html_length( $field, array &$add_html ) {
581
-        // check for max setting and if this field accepts maxlength
581
+		// check for max setting and if this field accepts maxlength
582 582
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) {
583
-            return;
584
-        }
583
+			return;
584
+		}
585 585
 
586 586
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
587
-            // don't load on form builder page
588
-            return;
589
-        }
587
+			// don't load on form builder page
588
+			return;
589
+		}
590 590
 
591 591
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
592
-    }
592
+	}
593 593
 
594 594
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
595 595
 		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -691,27 +691,27 @@  discard block
 block discarded – undo
691 691
 		}
692 692
 	}
693 693
 
694
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
695
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
696
-            return;
697
-        }
694
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
695
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
696
+			return;
697
+		}
698 698
 
699
-        foreach ( $field['shortcodes'] as $k => $v ) {
700
-            if ( 'opt' === $k ) {
701
-                continue;
702
-            }
699
+		foreach ( $field['shortcodes'] as $k => $v ) {
700
+			if ( 'opt' === $k ) {
701
+				continue;
702
+			}
703 703
 
704 704
 			if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
705
-                $add_html[] = $v;
706
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
705
+				$add_html[] = $v;
706
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
707 707
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
708
-            } else {
708
+			} else {
709 709
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
710
-            }
710
+			}
711 711
 
712 712
 			unset( $k, $v );
713
-        }
714
-    }
713
+		}
714
+	}
715 715
 
716 716
 	/**
717 717
 	 * Add pattern attribute
@@ -735,16 +735,16 @@  discard block
 block discarded – undo
735 735
 		}
736 736
 	}
737 737
 
738
-    public static function check_value( $opt, $opt_key, $field ) {
739
-        if ( is_array( $opt ) ) {
740
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
741
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
742
-            } else {
743
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
744
-            }
745
-        }
746
-        return $opt;
747
-    }
738
+	public static function check_value( $opt, $opt_key, $field ) {
739
+		if ( is_array( $opt ) ) {
740
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
741
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
742
+			} else {
743
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
744
+			}
745
+		}
746
+		return $opt;
747
+	}
748 748
 
749 749
 	public static function check_label( $opt ) {
750 750
 		if ( is_array( $opt ) ) {
Please login to merge, or discard this patch.