| @@ -101,9 +101,9 @@ | ||
| 101 | 101 | * @return bool True if the notification was successfully stored, false otherwise. |
| 102 | 102 | */ |
| 103 | 103 | public function record_log( $notification ) { |
| 104 | 104 | $sanitized_notification = $this->sanitize_notification( $notification ); |
| 105 | - if ( empty( $sanitized_notification ) ) { | |
| 105 | + if ( array() === $sanitized_notification ) { | |
| 106 | 106 | return false; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $notifications = $this->get_notifications(); |
| @@ -183,10 +183,10 @@ | ||
| 183 | 183 | * @param mixed $notification Notification data. |
| 184 | 184 | * |
| 185 | 185 | * @return array{id: string, timestamp: string|int, type: string, content: string, url: string} |
| 186 | 186 | */ |
| 187 | - private function sanitize_notification( $notification ) { | |
| 188 | - if ( empty( $notification['content'] ) ) { | |
| 187 | + private function sanitize_notification( $notification ): array { | |
| 188 | + if ( ! isset( $notification['content'] ) || '' === $notification['content'] ) { | |
| 189 | 189 | return array(); |
| 190 | 190 | } |
| 191 | 191 | // Sanitize and ensure all expected fields exist. |
| 192 | 192 | $sanitized = array(); |
| @@ -209,9 +209,9 @@ | ||
| 209 | 209 | * @return array Sanitized notification data. |
| 210 | 210 | */ |
| 211 | 211 | private function sanitize_notification_for_ui( $notification ) { |
| 212 | 212 | $sanitized = $this->sanitize_notification( $notification ); |
| 213 | - if ( empty( $sanitized['content'] ) ) { | |
| 213 | + if ( ! isset( $sanitized['content'] ) || '' === $sanitized['content'] ) { | |
| 214 | 214 | return array(); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | return $sanitized; |
| @@ -224,9 +224,9 @@ | ||
| 224 | 224 | */ |
| 225 | 225 | private function get_notifications_for_ui(): array { |
| 226 | 226 | $notifications = $this->get_notifications(); |
| 227 | 227 | |
| 228 | - if ( empty( $notifications ) ) { | |
| 228 | + if ( array() === $notifications ) { | |
| 229 | 229 | $this->record_log( |
| 230 | 230 | array( |
| 231 | 231 | 'module' => 'defender', |
| 232 | 232 | 'content' => esc_html__( 'Welcome to Defender', 'defender-security' ), |