Fix saving of checkboxes (off state) in widgets API

This commit is contained in:
Mike Jolley 2014-02-12 09:29:47 +00:00
parent 1f1a925fdd
commit fbfdc0ea95
1 changed files with 3 additions and 1 deletions

View File

@ -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;
} }
} }