| @@ -74,30 +74,18 @@ | ||
| 74 | 74 | */ |
| 75 | 75 | protected $db_row; |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | - * Field dropdowns will truncate at 25 characters by default. | |
| 79 | - * | |
| 80 | - * @var int|null | |
| 81 | - * | |
| 82 | - * @since 6.16.2 | |
| 83 | - */ | |
| 84 | - protected $truncate; | |
| 85 | - | |
| 86 | - /** | |
| 87 | 78 | * FrmFieldValueSelector constructor |
| 88 | 79 | * |
| 89 | - * @param int|string $field_id Field ID. | |
| 90 | - * @param array $args Arguments for configuring the value selector. | |
| 80 | + * @param int|string $field_id | |
| 91 | 81 | */ |
| 92 | 82 | public function __construct( $field_id, $args ) { |
| 93 | 83 | $this->set_html_name( $args ); |
| 94 | 84 | $this->set_value( $args ); |
| 95 | 85 | $this->set_source( $args ); |
| 96 | - $this->set_truncate( $args ); | |
| 97 | 86 | |
| 98 | 87 | $this->field_id = (int) $field_id; |
| 99 | - | |
| 100 | 88 | if ( $this->field_id === 0 ) { |
| 101 | 89 | return; |
| 102 | 90 | } |
| 103 | 91 | |
| @@ -102,15 +90,13 @@ | ||
| 102 | 90 | } |
| 103 | 91 | |
| 104 | 92 | $this->set_db_row(); |
| 105 | 93 | |
| 106 | - if ( ! $this->has_db_row() ) { | |
| 107 | - return; | |
| 94 | + if ( $this->has_db_row() ) { | |
| 95 | + $this->set_field_key(); | |
| 96 | + $this->set_field_settings(); | |
| 97 | + $this->set_options(); | |
| 108 | 98 | } |
| 109 | - | |
| 110 | - $this->set_field_key(); | |
| 111 | - $this->set_field_settings(); | |
| 112 | - $this->set_options(); | |
| 113 | 99 | } |
| 114 | 100 | |
| 115 | 101 | /** |
| 116 | 102 | * Set the db_row property |
| @@ -210,21 +196,8 @@ | ||
| 210 | 196 | } |
| 211 | 197 | } |
| 212 | 198 | |
| 213 | 199 | /** |
| 214 | - * @since 6.16.2 | |
| 215 | - * | |
| 216 | - * @param array $args | |
| 217 | - * | |
| 218 | - * @return void | |
| 219 | - */ | |
| 220 | - protected function set_truncate( $args ) { | |
| 221 | - if ( isset( $args['truncate'] ) && is_numeric( $args['truncate'] ) ) { | |
| 222 | - $this->truncate = (int) $args['truncate']; | |
| 223 | - } | |
| 224 | - } | |
| 225 | - | |
| 226 | - /** | |
| 227 | 200 | * Check if object has any options |
| 228 | 201 | * |
| 229 | 202 | * @since 2.03.05 |
| 230 | 203 | * |
| @@ -281,34 +254,20 @@ | ||
| 281 | 254 | protected function display_dropdown() { |
| 282 | 255 | echo '<select name="' . esc_attr( $this->html_name ) . '">'; |
| 283 | 256 | echo '<option value="">' . esc_html( $this->blank_option_label ) . '</option>'; |
| 284 | 257 | |
| 285 | - if ( $this->options ) { | |
| 286 | - $truncate = $this->truncate ?? 25; | |
| 287 | - | |
| 258 | + if ( ! empty( $this->options ) ) { | |
| 288 | 259 | foreach ( $this->options as $key => $value ) { |
| 289 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 290 | 260 | if ( $value == '' ) { |
| 291 | 261 | continue; |
| 292 | 262 | } |
| 293 | 263 | |
| 294 | 264 | $option = $this->get_single_field_option( $key, $value ); |
| 295 | - $option->print_single_option( $this->value, $truncate, $this->use_value_as_label_in_dropdown() ); | |
| 265 | + $option->print_single_option( $this->value, 25 ); | |
| 296 | 266 | } |
| 297 | 267 | } |
| 298 | 268 | |
| 299 | 269 | 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 | 270 | } |
| 312 | 271 | |
| 313 | 272 | /** |
| 314 | 273 | * Get an instance of FrmFieldOption |