- fixed save empty value to the selectbox;

This commit is contained in:
nikitasinelnikov
2019-05-13 17:19:12 +03:00
parent efbfb97567
commit 0408067a6b
3 changed files with 22 additions and 18 deletions
+4 -3
View File
@@ -73,16 +73,17 @@ if ( ! class_exists( 'um\core\Validation' ) ) {
}
//validation of correct values from options in wp-admin
$stripslashes = stripslashes( $value );
if ( in_array( $fields[ $key ]['type'], array( 'select' ) ) &&
isset( $value ) && ! empty( $fields[ $key ]['options'] ) &&
! in_array( stripslashes( $value ), array_map( 'trim', $fields[ $key ]['options'] ) ) ) {
! empty( $stripslashes ) && ! empty( $fields[ $key ]['options'] ) &&
! in_array( $stripslashes, array_map( 'trim', $fields[ $key ]['options'] ) ) ) {
unset( $changes[ $key ] );
}
//validation of correct values from options in wp-admin
//the user cannot set invalid value in the hidden input at the page
if ( in_array( $fields[ $key ]['type'], array( 'multiselect', 'checkbox', 'radio' ) ) &&
isset( $value ) && ! empty( $fields[ $key ]['options'] ) ) {
! empty( $value ) && ! empty( $fields[ $key ]['options'] ) ) {
$value = array_map( 'stripslashes', array_map( 'trim', $value ) );
$changes[ $key ] = array_intersect( $value, array_map( 'trim', $fields[ $key ]['options'] ) );
}