| @@ -49,9 +49,9 @@ | ||
| 49 | 49 | * @return void |
| 50 | 50 | */ |
| 51 | 51 | private function set_option_label() { |
| 52 | 52 | if ( is_array( $this->option ) ) { |
| 53 | - $this->option_label = ( $this->option['label'] ?? reset( $this->option ) ); | |
| 53 | + $this->option_label = ( isset( $this->option['label'] ) ? $this->option['label'] : reset( $this->option ) ); | |
| 54 | 54 | } else { |
| 55 | 55 | $this->option_label = $this->option; |
| 56 | 56 | } |
| 57 | 57 | } |
| @@ -71,28 +71,19 @@ | ||
| 71 | 71 | * Print a single option |
| 72 | 72 | * |
| 73 | 73 | * @since 2.03.05 |
| 74 | 74 | * |
| 75 | - * @param string $selected_value The value of the option to be selected. | |
| 76 | - * @param int $truncate Truncate the option label if true. | |
| 77 | - * @param bool $use_value_as_label Use the option value as the label if true. | |
| 75 | + * @param string $selected_value | |
| 76 | + * @param int $truncate | |
| 78 | 77 | * |
| 79 | 78 | * @return void |
| 80 | 79 | */ |
| 81 | - public function print_single_option( $selected_value, $truncate, $use_value_as_label = false ) { | |
| 82 | - if ( '' === $this->saved_value && ! $use_value_as_label ) { | |
| 83 | - 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>'; | |
| 84 | 87 | } |
| 85 | - | |
| 86 | - if ( $use_value_as_label && '' === trim( $this->option_label ) ) { | |
| 87 | - $label = '' !== (string) $this->saved_value ? $this->saved_value : FrmAppHelper::get_no_label_text(); | |
| 88 | - } else { | |
| 89 | - $label = $this->option_label; | |
| 90 | - } | |
| 91 | - | |
| 92 | - echo '<option value="' . esc_attr( $this->saved_value ) . '"'; | |
| 93 | - selected( esc_attr( $selected_value ), esc_attr( $this->saved_value ) ); | |
| 94 | - // TODO: add hook that can add attributes to option text | |
| 95 | - echo '>'; | |
| 96 | - echo esc_html( FrmAppHelper::truncate( $label, $truncate ) ) . '</option>'; | |
| 97 | 88 | } |
| 98 | 89 | } |