From 12a5be9be286d09a83e762ffe0fbc1c44db74bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rabbi=20Islam=20Rony=20=E2=9A=A1=EF=B8=8F?= <35329385+RabbiIslamRony@users.noreply.github.com> Date: Mon, 24 Aug 2026 20:01:42 +0600 Subject: [PATCH] fix: preserve empty optional dropdown values --- templates/listing-form/custom-fields/select.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/templates/listing-form/custom-fields/select.php b/templates/listing-form/custom-fields/select.php index ac8d2b9fc1..8df27290ff 100644 --- a/templates/listing-form/custom-fields/select.php +++ b/templates/listing-form/custom-fields/select.php @@ -2,24 +2,34 @@ /** * @author wpWax * @since 6.6 - * @version 8.6 + * @version 8.9.4 */ if ( ! defined( 'ABSPATH' ) ) exit; // Get conditional logic attributes using centralized method $conditional_logic_attr = $listing_form->get_conditional_logic_attributes( $data ); +$options = ! empty( $data['options'] ) && is_array( $data['options'] ) ? $data['options'] : []; +$has_empty_option = in_array( '', wp_list_pluck( $options, 'option_value' ), true ); +$show_empty_option = empty( $data['required'] ) && ! $has_empty_option; +$placeholder = ! empty( $data['placeholder'] ) ? $data['placeholder'] : __( 'Select...', 'directorist' ); ?>