Skip to content

Commit

Permalink
Avoid PHP notices when widget is first added
Browse files Browse the repository at this point in the history
  • Loading branch information
jeherve committed Oct 18, 2024
1 parent fac6440 commit 76c0fa3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions projects/packages/search/src/widgets/class-search-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,8 @@ public function update( $new_instance, $old_instance ) { // phpcs:ignore Variabl
// Keep `search_box_enabled` and `user_sort_enabled` settings when updating widget on Instant Search
// Set `search_box_enabled` and `user_sort_enabled` default to '1' when createing a NEW widget
if ( Options::is_instant_enabled() ) {
$instance['search_box_enabled'] = empty( $old_instance ) ? '1' : $old_instance['search_box_enabled'];
$instance['user_sort_enabled'] = empty( $old_instance ) ? '1' : $old_instance['user_sort_enabled'];
$instance['search_box_enabled'] = empty( $old_instance ) || empty( $old_instance['search_box_enabled'] ) ? '1' : $old_instance['search_box_enabled'];
$instance['user_sort_enabled'] = empty( $old_instance ) || empty( $old_instance['user_sort_enabled'] ) ? '1' : $old_instance['user_sort_enabled'];
} else {
$instance['search_box_enabled'] = empty( $new_instance['search_box_enabled'] ) ? '0' : '1';
$instance['user_sort_enabled'] = empty( $new_instance['user_sort_enabled'] ) ? '0' : '1';
Expand Down

0 comments on commit 76c0fa3

Please sign in to comment.