Convert allowed options to string values for comparison, html options have no data type distiction.

This commit is contained in:
Gerhard Potgieter 2017-12-15 13:39:05 +02:00
parent 30398a65f1
commit 89d21a50a4
1 changed files with 2 additions and 2 deletions

View File

@ -727,13 +727,13 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
}
break;
case 'select':
$allowed_values = empty( $option['options'] ) ? array() : array_keys( $option['options'] );
$allowed_values = empty( $option['options'] ) ? array() : array_map( 'strval', array_keys( $option['options'] ) );
if ( empty( $option['default'] ) && empty( $allowed_values ) ) {
$value = null;
break;
}
$default = ( empty( $option['default'] ) ? $allowed_values[0] : $option['default'] );
$value = in_array( $raw_value, $allowed_values ) ? $raw_value : $default;
$value = in_array( $raw_value, $allowed_values, true ) ? $raw_value : $default;
break;
default:
$value = wc_clean( $raw_value );