Fix saving of checkboxes (off state) in widgets API
This commit is contained in:
parent
1f1a925fdd
commit
fbfdc0ea95
|
@ -82,8 +82,10 @@ abstract class WC_Widget extends WP_Widget {
|
||||||
return $instance;
|
return $instance;
|
||||||
|
|
||||||
foreach ( $this->settings as $key => $setting ) {
|
foreach ( $this->settings as $key => $setting ) {
|
||||||
if ( isset( $new_instance[$key] ) ) {
|
if ( isset( $new_instance[ $key ] ) ) {
|
||||||
$instance[ $key ] = sanitize_text_field( $new_instance[ $key ] );
|
$instance[ $key ] = sanitize_text_field( $new_instance[ $key ] );
|
||||||
|
} elseif ( 'checkbox' === $setting['type'] ) {
|
||||||
|
$instance[ $key ] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue