Skip to content

Commit 53d83ab

Browse files
Fix tabs changes not saving in the block widget editor
1 parent 43028a4 commit 53d83ab

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

inc/widgets/class-mongoose-page-plugin-facebook-page-widget.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public function form( $instance ) {
316316
}
317317
foreach ( $cjw_fbpp_tabs as $tab ) {
318318
printf(
319-
'<br/><label><input type="checkbox" name="%1$s[%2$s]" %3$s /> %4$s</label>',
319+
'<br/><label><input type="checkbox" name="%1$s[]" value="%2$s" %3$s /> %4$s</label>',
320320
esc_attr( $this->get_field_name( 'tabs' ) ),
321321
esc_attr( $tab ),
322322
in_array( $tab, $tabs, true ) ? 'checked' : '',
@@ -421,9 +421,10 @@ public function update( $new_instance, $old_instance ) {
421421
$instance['cover'] = ( ! empty( $new_instance['cover'] ) ) ? wp_strip_all_tags( $new_instance['cover'] ) : '';
422422
$instance['facepile'] = ( ! empty( $new_instance['facepile'] ) ) ? wp_strip_all_tags( $new_instance['facepile'] ) : '';
423423
if ( ! empty( $new_instance['tabs'] ) ) {
424+
$instance['tabs'] = $new_instance['tabs'];
424425
if ( is_array( $new_instance['tabs'] ) ) {
425-
foreach ( $new_instance['tabs'] as $key => $var ) {
426-
$instance['tabs'][] = sanitize_text_field( $key );
426+
for ( $i = 0, $c = count( $new_instance['tabs'] ); $i < $c; $i++ ) {
427+
$instance['tabs'][] = wp_strip_all_tags( $new_instance['tabs'][ $i ] );
427428
}
428429
}
429430
} else {

0 commit comments

Comments
 (0)