diff --git a/custom_metadata.php b/custom_metadata.php index 6aa50aa..afe827f 100644 --- a/custom_metadata.php +++ b/custom_metadata.php @@ -1063,14 +1063,24 @@ function _sanitize_field_value( $field_slug, $field, $object_type, $object_id, $ $sanitize_callback = $this->get_sanitize_callback( $field, $object_type ); + if ( $sanitize_callback ) + return call_user_func( $sanitize_callback, $field_slug, $field, $object_type, $object_id, $value ); + // convert date to unix timestamp if ( in_array( $field->field_type, array( 'datepicker', 'datetimepicker', 'timepicker' ) ) ) { - $value = strtotime( $value ); + + // if $value is an array, we need to sanitize every value in the array + if( is_array( $value ) ) { + $result = array(); + foreach ( $value as $val ) { + $result[] = strtotime( $val ); + } + $value = $result; + } else { + $value = strtotime( $value ); + } } - if ( $sanitize_callback ) - return call_user_func( $sanitize_callback, $field_slug, $field, $object_type, $object_id, $value ); - return $value; }