When saving settings, only allow values found in “options” for “select” type fields.
This commit is contained in:
parent
a0f227a17c
commit
e14d77a987
|
@ -718,6 +718,15 @@ class WC_Admin_Settings {
|
||||||
$value['crop'] = $option['default']['crop'];
|
$value['crop'] = $option['default']['crop'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'select':
|
||||||
|
$allowed_values = empty( $option['options'] ) ? array() : 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;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
$value = wc_clean( $raw_value );
|
$value = wc_clean( $raw_value );
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue