diff --git a/includes/abstracts/abstract-wc-widget.php b/includes/abstracts/abstract-wc-widget.php index df63a031ce0..9e99783172e 100644 --- a/includes/abstracts/abstract-wc-widget.php +++ b/includes/abstracts/abstract-wc-widget.php @@ -142,8 +142,17 @@ abstract class WC_Widget extends WP_Widget { } foreach ( $this->settings as $key => $setting ) { + if ( 'number' === $setting['type'] ) { + $instance[ $key ] = sanitize_text_field( $new_instance[ $key ] ); - if ( isset( $new_instance[ $key ] ) ) { + if ( isset( $setting['min'] ) && '' !== $setting['min'] ) { + $instance[ $key ] = max( $instance[ $key ], $setting['min'] ); + } + + if ( isset( $setting['max'] ) && '' !== $setting['max'] ) { + $instance[ $key ] = min( $instance[ $key ], $setting['max'] ); + } + } elseif ( isset( $new_instance[ $key ] ) ) { $instance[ $key ] = sanitize_text_field( $new_instance[ $key ] ); } elseif ( 'checkbox' === $setting['type'] ) { $instance[ $key ] = 0;