| @@ -25,13 +25,13 @@ | ||
| 25 | 25 | */ |
| 26 | 26 | protected $field_key = ''; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * @var null | |
| 29 | + * @var FrmProFieldSettings|null | |
| 30 | 30 | * |
| 31 | 31 | * @since 2.03.05 |
| 32 | 32 | */ |
| 33 | - protected $field_settings = null; | |
| 33 | + protected $field_settings; | |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @var array |
| 37 | 37 | * |
| @@ -67,15 +67,24 @@ | ||
| 67 | 67 | */ |
| 68 | 68 | protected $blank_option_label = ''; |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * @var object | |
| 71 | + * @var object|null | |
| 72 | 72 | * |
| 73 | 73 | * @since 2.03.05 |
| 74 | 74 | */ |
| 75 | - protected $db_row = null; | |
| 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 | + /** | |
| 78 | 87 | * FrmFieldValueSelector constructor |
| 79 | 88 | * |
| 80 | 89 | * @param int|string $field_id |
| 81 | 90 | */ |
| @@ -82,8 +91,9 @@ | ||
| 82 | 91 | public function __construct( $field_id, $args ) { |
| 83 | 92 | $this->set_html_name( $args ); |
| 84 | 93 | $this->set_value( $args ); |
| 85 | 94 | $this->set_source( $args ); |
| 95 | + $this->set_truncate( $args ); | |
| 86 | 96 | |
| 87 | 97 | $this->field_id = (int) $field_id; |
| 88 | 98 | if ( $this->field_id === 0 ) { |
| 89 | 99 | return; |
| @@ -196,8 +206,21 @@ | ||
| 196 | 206 | } |
| 197 | 207 | } |
| 198 | 208 | |
| 199 | 209 | /** |
| 210 | + * @since 6.16.2 | |
| 211 | + * | |
| 212 | + * @param array $args | |
| 213 | + * | |
| 214 | + * @return void | |
| 215 | + */ | |
| 216 | + protected function set_truncate( $args ) { | |
| 217 | + if ( isset( $args['truncate'] ) && is_numeric( $args['truncate'] ) ) { | |
| 218 | + $this->truncate = (int) $args['truncate']; | |
| 219 | + } | |
| 220 | + } | |
| 221 | + | |
| 222 | + /** | |
| 200 | 223 | * Check if object has any options |
| 201 | 224 | * |
| 202 | 225 | * @since 2.03.05 |
| 203 | 226 | * |
| @@ -252,11 +275,13 @@ | ||
| 252 | 275 | * @return void |
| 253 | 276 | */ |
| 254 | 277 | protected function display_dropdown() { |
| 255 | 278 | echo '<select name="' . esc_attr( $this->html_name ) . '">'; |
| 256 | - echo '<option value="">' . esc_attr( $this->blank_option_label ) . '</option>'; | |
| 279 | + echo '<option value="">' . esc_html( $this->blank_option_label ) . '</option>'; | |
| 257 | 280 | |
| 258 | 281 | if ( ! empty( $this->options ) ) { |
| 282 | + $truncate = isset( $this->truncate ) ? $this->truncate : 25; | |
| 283 | + | |
| 259 | 284 | foreach ( $this->options as $key => $value ) { |
| 260 | 285 | if ( $value == '' ) { |
| 261 | 286 | continue; |
| 262 | 287 | } |
| @@ -261,9 +286,9 @@ | ||
| 261 | 286 | continue; |
| 262 | 287 | } |
| 263 | 288 | |
| 264 | 289 | $option = $this->get_single_field_option( $key, $value ); |
| 265 | - $option->print_single_option( $this->value, 25 ); | |
| 290 | + $option->print_single_option( $this->value, $truncate ); | |
| 266 | 291 | } |
| 267 | 292 | } |
| 268 | 293 | |
| 269 | 294 | echo '</select>'; |