PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.19
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.19
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 +14 -28 6.286.19 View file →
@@ -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();
@@ -57,9 +48,13 @@
57 48 *
58 49 * @return void
59 50 */
60 51 private function set_option_label() {
61 - $this->option_label = is_array( $this->option ) ? ( $this->option['label'] ?? reset( $this->option ) ) : $this->option;
52 + if ( is_array( $this->option ) ) {
53 + $this->option_label = ( isset( $this->option['label'] ) ? $this->option['label'] : reset( $this->option ) );
54 + } else {
55 + $this->option_label = $this->option;
56 + }
62 57 }
63 58
64 59 /**
65 60 * Set the saved value
@@ -76,28 +71,19 @@
76 71 * Print a single option
77 72 *
78 73 * @since 2.03.05
79 74 *
80 - * @param string $selected_value The value of the option to be selected.
81 - * @param int $truncate Truncate the option label if true.
82 - * @param bool $use_value_as_label Use the option value as the label if true.
75 + * @param string $selected_value
76 + * @param int $truncate
83 77 *
84 78 * @return void
85 79 */
86 - public function print_single_option( $selected_value, $truncate, $use_value_as_label = false ) {
87 - if ( '' === $this->saved_value && ! $use_value_as_label ) {
88 - return;
80 + public function print_single_option( $selected_value, $truncate ) {
81 + if ( '' !== $this->saved_value ) {
82 + echo '<option value="' . esc_attr( $this->saved_value ) . '"';
83 + selected( esc_attr( $selected_value ), esc_attr( $this->saved_value ) );
84 + // TODO: add hook that can add attributes to option text
85 + echo '>';
86 + echo esc_html( FrmAppHelper::truncate( $this->option_label, $truncate ) ) . '</option>';
89 87 }
90 -
91 - if ( $use_value_as_label && '' === trim( $this->option_label ) ) {
92 - $label = '' !== $this->saved_value ? $this->saved_value : FrmAppHelper::get_no_label_text();
93 - } else {
94 - $label = $this->option_label;
95 - }
96 -
97 - echo '<option value="' . esc_attr( $this->saved_value ) . '"';
98 - selected( esc_attr( $selected_value ), esc_attr( $this->saved_value ) );
99 - // TODO: add hook that can add attributes to option text
100 - echo '>';
101 - echo esc_html( FrmAppHelper::truncate( $label, $truncate ) ) . '</option>';
102 88 }
103 89 }