| @@ -141,21 +141,21 @@ | ||
| 141 | 141 | * @return array Updated safe values to be saved. |
| 142 | 142 | */ |
| 143 | 143 | public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 144 | 144 | $instance = array(); |
| 145 | - $instance['title'] = wp_kses( $new_instance['title'], array() ); | |
| 145 | + $instance['title'] = wp_kses( $new_instance['title'] ?? '', array() ); | |
| 146 | 146 | if ( $instance['title'] === $this->default_title ) { |
| 147 | 147 | $instance['title'] = false; // Store as false in case of language change. |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $instance['number'] = (int) $new_instance['number']; | |
| 150 | + $instance['number'] = (int) ( $new_instance['number'] ?? 0 ); | |
| 151 | 151 | if ( ! in_array( $instance['number'], array( 10, 50 ), true ) ) { |
| 152 | 152 | $instance['number'] = 10; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - $instance['include_likers'] = (bool) $new_instance['include_likers']; | |
| 156 | - $instance['include_followers'] = (bool) $new_instance['include_followers']; | |
| 157 | - $instance['include_commenters'] = (bool) $new_instance['include_commenters']; | |
| 155 | + $instance['include_likers'] = ! empty( $new_instance['include_likers'] ); | |
| 156 | + $instance['include_followers'] = ! empty( $new_instance['include_followers'] ); | |
| 157 | + $instance['include_commenters'] = ! empty( $new_instance['include_commenters'] ); | |
| 158 | 158 | |
| 159 | 159 | delete_transient( "$this->id-v2-{$instance['number']}" . (int) $instance['include_likers'] . (int) $instance['include_followers'] . (int) $instance['include_commenters'] ); |
| 160 | 160 | |
| 161 | 161 | return $instance; |
| @@ -169,8 +169,17 @@ | ||
| 169 | 169 | * @param array $args Widget arguments. |
| 170 | 170 | * @param array $instance Saved values from database. |
| 171 | 171 | */ |
| 172 | 172 | public function widget( $args, $instance ) { |
| 173 | + $args = wp_parse_args( | |
| 174 | + $args, | |
| 175 | + array( | |
| 176 | + 'before_widget' => '', | |
| 177 | + 'after_widget' => '', | |
| 178 | + 'before_title' => '', | |
| 179 | + 'after_title' => '', | |
| 180 | + ) | |
| 181 | + ); | |
| 173 | 182 | $instance = wp_parse_args( |
| 174 | 183 | $instance, |
| 175 | 184 | array( |
| 176 | 185 | 'title' => false, |