Handle select options in setting sanitization function.

This commit is contained in:
Jeff Stieler 2016-06-07 16:54:28 -06:00 committed by Justin Shreve
parent 24014a5d04
commit 9d9d318727
1 changed files with 5 additions and 0 deletions

View File

@ -87,6 +87,11 @@ class WC_REST_Settings_API_Controller extends WC_REST_Controller {
$value['crop'] = $setting['default']['crop']; $value['crop'] = $setting['default']['crop'];
} }
break; break;
case 'select':
$options = array_keys( $setting['options'] );
$default = ( empty( $setting['default'] ) ? $options[0] : $setting['default'] );
$value = in_array( $raw_value, $options ) ? $raw_value : $default;
break;
default : default :
$value = wc_clean( $raw_value ); $value = wc_clean( $raw_value );
break; break;