notificationService = $notificationService; } /** * @param WP_REST_Request $data * * @return WP_REST_Response * * @throws InvalidArgumentException * @throws ForbiddenException */ public function handle(WP_REST_Request $data): WP_REST_Response { // Verify the nonce Sanitizer::verifyNonce($data->get_header('X-WP-Nonce')); $notificationId = Sanitizer::sanitizeId($data->get_param('id')); if (empty($notificationId)) { throw new InvalidArgumentException('Notification ID is required.'); } $this->notificationService->deleteNotification($notificationId); return new WP_REST_Response([ 'message' => 'Successfully deleted notification.', 'data' => [] ], 200); } }