| @@ -85,9 +85,10 @@ | ||
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * FrmFieldValueSelector constructor |
| 88 | 88 | * |
| 89 | - * @param int|string $field_id | |
| 89 | + * @param int|string $field_id Field ID. | |
| 90 | + * @param array $args Arguments for configuring the value selector. | |
| 90 | 91 | */ |
| 91 | 92 | public function __construct( $field_id, $args ) { |
| 92 | 93 | $this->set_html_name( $args ); |
| 93 | 94 | $this->set_value( $args ); |
| @@ -94,8 +95,9 @@ | ||
| 94 | 95 | $this->set_source( $args ); |
| 95 | 96 | $this->set_truncate( $args ); |
| 96 | 97 | |
| 97 | 98 | $this->field_id = (int) $field_id; |
| 99 | + | |
| 98 | 100 | if ( $this->field_id === 0 ) { |
| 99 | 101 | return; |
| 100 | 102 | } |
| 101 | 103 | |
| @@ -100,13 +102,15 @@ | ||
| 100 | 102 | } |
| 101 | 103 | |
| 102 | 104 | $this->set_db_row(); |
| 103 | 105 | |
| 104 | - if ( $this->has_db_row() ) { | |
| 105 | - $this->set_field_key(); | |
| 106 | - $this->set_field_settings(); | |
| 107 | - $this->set_options(); | |
| 106 | + if ( ! $this->has_db_row() ) { | |
| 107 | + return; | |
| 108 | 108 | } |
| 109 | + | |
| 110 | + $this->set_field_key(); | |
| 111 | + $this->set_field_settings(); | |
| 112 | + $this->set_options(); | |
| 109 | 113 | } |
| 110 | 114 | |
| 111 | 115 | /** |
| 112 | 116 | * Set the db_row property |
| @@ -277,12 +281,13 @@ | ||
| 277 | 281 | protected function display_dropdown() { |
| 278 | 282 | echo '<select name="' . esc_attr( $this->html_name ) . '">'; |
| 279 | 283 | echo '<option value="">' . esc_html( $this->blank_option_label ) . '</option>'; |
| 280 | 284 | |
| 281 | - if ( ! empty( $this->options ) ) { | |
| 285 | + if ( $this->options ) { | |
| 282 | 286 | $truncate = $this->truncate ?? 25; |
| 283 | 287 | |
| 284 | 288 | foreach ( $this->options as $key => $value ) { |
| 289 | + // phpcs:ignore Universal.Operators.StrictComparisons | |
| 285 | 290 | if ( $value == '' ) { |
| 286 | 291 | continue; |
| 287 | 292 | } |
| 288 | 293 | |