| @@ -85,10 +85,9 @@ | ||
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * FrmFieldValueSelector constructor |
| 88 | 88 | * |
| 89 | - * @param int|string $field_id Field ID. | |
| 90 | - * @param array $args Arguments for configuring the value selector. | |
| 89 | + * @param int|string $field_id | |
| 91 | 90 | */ |
| 92 | 91 | public function __construct( $field_id, $args ) { |
| 93 | 92 | $this->set_html_name( $args ); |
| 94 | 93 | $this->set_value( $args ); |
| @@ -95,9 +94,8 @@ | ||
| 95 | 94 | $this->set_source( $args ); |
| 96 | 95 | $this->set_truncate( $args ); |
| 97 | 96 | |
| 98 | 97 | $this->field_id = (int) $field_id; |
| 99 | - | |
| 100 | 98 | if ( $this->field_id === 0 ) { |
| 101 | 99 | return; |
| 102 | 100 | } |
| 103 | 101 | |
| @@ -102,15 +100,13 @@ | ||
| 102 | 100 | } |
| 103 | 101 | |
| 104 | 102 | $this->set_db_row(); |
| 105 | 103 | |
| 106 | - if ( ! $this->has_db_row() ) { | |
| 107 | - return; | |
| 104 | + if ( $this->has_db_row() ) { | |
| 105 | + $this->set_field_key(); | |
| 106 | + $this->set_field_settings(); | |
| 107 | + $this->set_options(); | |
| 108 | 108 | } |
| 109 | - | |
| 110 | - $this->set_field_key(); | |
| 111 | - $this->set_field_settings(); | |
| 112 | - $this->set_options(); | |
| 113 | 109 | } |
| 114 | 110 | |
| 115 | 111 | /** |
| 116 | 112 | * Set the db_row property |
| @@ -281,34 +277,22 @@ | ||
| 281 | 277 | protected function display_dropdown() { |
| 282 | 278 | echo '<select name="' . esc_attr( $this->html_name ) . '">'; |
| 283 | 279 | echo '<option value="">' . esc_html( $this->blank_option_label ) . '</option>'; |
| 284 | 280 | |
| 285 | - if ( $this->options ) { | |
| 286 | - $truncate = $this->truncate ?? 25; | |
| 281 | + if ( ! empty( $this->options ) ) { | |
| 282 | + $truncate = isset( $this->truncate ) ? $this->truncate : 25; | |
| 287 | 283 | |
| 288 | 284 | foreach ( $this->options as $key => $value ) { |
| 289 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 290 | 285 | if ( $value == '' ) { |
| 291 | 286 | continue; |
| 292 | 287 | } |
| 293 | 288 | |
| 294 | 289 | $option = $this->get_single_field_option( $key, $value ); |
| 295 | - $option->print_single_option( $this->value, $truncate, $this->use_value_as_label_in_dropdown() ); | |
| 290 | + $option->print_single_option( $this->value, $truncate ); | |
| 296 | 291 | } |
| 297 | 292 | } |
| 298 | 293 | |
| 299 | 294 | echo '</select>'; |
| 300 | - } | |
| 301 | - | |
| 302 | - /** | |
| 303 | - * Whether to use the field value as the option label in the dropdown when the label is empty. | |
| 304 | - * | |
| 305 | - * @since 6.25.1 | |
| 306 | - * | |
| 307 | - * @return bool | |
| 308 | - */ | |
| 309 | - protected function use_value_as_label_in_dropdown() { | |
| 310 | - return false; | |
| 311 | 295 | } |
| 312 | 296 | |
| 313 | 297 | /** |
| 314 | 298 | * Get an instance of FrmFieldOption |