Skip to content

Commit 79d87b2

Browse files
committed
Fix: Allow deleting notes when enabled in settings #159
1 parent 79b82bb commit 79d87b2

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

disable-comments.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,21 @@ private function is_allowed_comment_type_request($request = null) {
645645
}
646646
}
647647
}
648+
649+
// For DELETE requests, extract comment ID from the route path
650+
// The comment ID is only in the URL (e.g., /wp/v2/comments/123), not in request params
651+
if (!$comment_type && $request->is_method('DELETE')) {
652+
$route_parts = explode('/', $request->get_route());
653+
$comment_id = end($route_parts);
654+
655+
// Ensure we have a numeric comment ID
656+
if (is_numeric($comment_id)) {
657+
$comment = get_comment((int) $comment_id);
658+
if ($comment && isset($comment->comment_type)) {
659+
$comment_type = $comment->comment_type;
660+
}
661+
}
662+
}
648663
}
649664

650665
// Check if the comment type is in the allowlist

0 commit comments

Comments
 (0)