Skip to content

Commit

Permalink
Fix tabs changes not saving in the block widget editor
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronjonesweb committed Aug 27, 2023
1 parent 43028a4 commit 53d83ab
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public function form( $instance ) {
}
foreach ( $cjw_fbpp_tabs as $tab ) {
printf(
'<br/><label><input type="checkbox" name="%1$s[%2$s]" %3$s /> %4$s</label>',
'<br/><label><input type="checkbox" name="%1$s[]" value="%2$s" %3$s /> %4$s</label>',
esc_attr( $this->get_field_name( 'tabs' ) ),
esc_attr( $tab ),
in_array( $tab, $tabs, true ) ? 'checked' : '',
Expand Down Expand Up @@ -421,9 +421,10 @@ public function update( $new_instance, $old_instance ) {
$instance['cover'] = ( ! empty( $new_instance['cover'] ) ) ? wp_strip_all_tags( $new_instance['cover'] ) : '';
$instance['facepile'] = ( ! empty( $new_instance['facepile'] ) ) ? wp_strip_all_tags( $new_instance['facepile'] ) : '';
if ( ! empty( $new_instance['tabs'] ) ) {
$instance['tabs'] = $new_instance['tabs'];
if ( is_array( $new_instance['tabs'] ) ) {
foreach ( $new_instance['tabs'] as $key => $var ) {
$instance['tabs'][] = sanitize_text_field( $key );
for ( $i = 0, $c = count( $new_instance['tabs'] ); $i < $c; $i++ ) {
$instance['tabs'][] = wp_strip_all_tags( $new_instance['tabs'][ $i ] );
}
}
} else {
Expand Down

0 comments on commit 53d83ab

Please sign in to comment.