PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmFieldOption.php +12 -36 6.265.0 View file →
@@ -8,9 +8,9 @@
8 8 */
9 9 class FrmFieldOption {
10 10
11 11 /**
12 - * @var int|string
12 + * @var string|int
13 13 *
14 14 * @since 2.03.05
15 15 */
16 16 protected $option_key;
@@ -15,9 +15,9 @@
15 15 */
16 16 protected $option_key;
17 17
18 18 /**
19 - * @var array|string
19 + * @var string|array
20 20 *
21 21 * @since 2.03.05
22 22 */
23 23 protected $option;
@@ -23,9 +23,8 @@
23 23 protected $option;
24 24
25 25 /**
26 26 * @var string
27 - *
28 27 * @since 2.03.05
29 28 */
30 29 protected $saved_value = '';
31 30
@@ -30,20 +29,12 @@
30 29 protected $saved_value = '';
31 30
32 31 /**
33 32 * @var string
34 - *
35 33 * @since 2.03.05
36 34 */
37 35 protected $option_label = '';
38 36
39 - /**
40 - * @param int|string $option_key
41 - * @param array|string $option
42 - * @param array $args
43 - *
44 - * @return void
45 - */
46 37 public function __construct( $option_key, $option, $args = array() ) {
47 38 $this->option_key = $option_key;
48 39 $this->option = $option;
49 40 $this->set_option_label();
@@ -53,14 +44,12 @@
53 44 /**
54 45 * Set the option label
55 46 *
56 47 * @since 2.03.05
57 - *
58 - * @return void
59 48 */
60 49 private function set_option_label() {
61 50 if ( is_array( $this->option ) ) {
62 - $this->option_label = ( $this->option['label'] ?? reset( $this->option ) );
51 + $this->option_label = ( isset( $this->option['label'] ) ? $this->option['label'] : reset( $this->option ) );
63 52 } else {
64 53 $this->option_label = $this->option;
65 54 }
66 55 }
@@ -68,10 +57,8 @@
68 57 /**
69 58 * Set the saved value
70 59 *
71 60 * @since 2.03.05
72 - *
73 - * @return void
74 61 */
75 62 protected function set_saved_value() {
76 63 $this->saved_value = $this->option_label;
77 64 }
@@ -80,28 +67,17 @@
80 67 * Print a single option
81 68 *
82 69 * @since 2.03.05
83 70 *
84 - * @param string $selected_value The value of the option to be selected.
85 - * @param int $truncate Truncate the option label if true.
86 - * @param bool $use_value_as_label Use the option value as the label if true.
87 - *
88 - * @return void
71 + * @param string $selected_value
72 + * @param int $truncate
89 73 */
90 - public function print_single_option( $selected_value, $truncate, $use_value_as_label = false ) {
91 - if ( '' === $this->saved_value && ! $use_value_as_label ) {
92 - return;
74 + public function print_single_option( $selected_value, $truncate ) {
75 + if ( '' !== $this->saved_value ) {
76 + echo '<option value="' . esc_attr( $this->saved_value ) . '"';
77 + selected( esc_attr( $selected_value ), esc_attr( $this->saved_value ) );
78 + // TODO: add hook that can add attributes to option text
79 + echo '>';
80 + echo esc_html( FrmAppHelper::truncate( $this->option_label, $truncate ) ) . '</option>';
93 81 }
94 -
95 - if ( $use_value_as_label && '' === trim( $this->option_label ) ) {
96 - $label = '' !== $this->saved_value ? $this->saved_value : FrmAppHelper::get_no_label_text();
97 - } else {
98 - $label = $this->option_label;
99 - }
100 -
101 - echo '<option value="' . esc_attr( $this->saved_value ) . '"';
102 - selected( esc_attr( $selected_value ), esc_attr( $this->saved_value ) );
103 - // TODO: add hook that can add attributes to option text
104 - echo '>';
105 - echo esc_html( FrmAppHelper::truncate( $label, $truncate ) ) . '</option>';
106 82 }
107 83 }