Comments: Allow changing a comment's parent from the Edit Comment screen#12406
Comments: Allow changing a comment's parent from the Edit Comment screen#12406youknowriad wants to merge 1 commit into
Conversation
…een. Adds an editable 'In reply to' control to the Edit Comment screen, following the pattern of the 'Submitted on' toggle: an Edit link reveals a select of the other comments on the same post (author and trimmed excerpt), excluding the comment itself and its descendants. edit_comment() now reads comment_parent from the submitted form and validates it before updating: the parent must be another comment on the same post, and cannot be the comment itself or one of its descendants, preventing threading loops. Trac ticket: https://core.trac.wordpress.org/ticket/65570 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There is currently no way to re-parent a comment (change
comment_parent) through the admin UI, even though the data layer fully supports it (wp_update_comment()listscomment_parentamong its updatable fields, and the REST API acceptsparenton update).This PR adds an editable "In reply to" control to the Edit Comment screen:
<select>of the other comments on the same post, each option labeled with the comment author and a trimmed excerpt (viaget_comment_excerpt()). The comment being edited and its descendants are excluded from the list, so a threading loop cannot even be selected. If the current parent would not otherwise be listed (e.g. a pingback, or a comment no longer publicly visible), it is appended as a selected option so saving without touching the field never re-parents the comment.edit_comment()now readscomment_parentfrom the submitted form and validates it before handing off towp_update_comment(): the parent must be another comment on the same post, and cannot be the comment itself or one of its descendants. Invalid values return aWP_Error, surfaced the same way as other comment update failures. The quick-edit AJAX path is unaffected, as its form does not submitcomment_parent.Note on UI scope: the UI is intentionally kept minimal for now (a plain
select). The Edit Comment screen is a non-React admin screen, so advanced UI components (custom searchable selects/comboboxes) are hard to do well there without pulling in significant machinery. The plain select matches the existing core precedent for picking a parent (wp_dropdown_pages()in Page Attributes) and can be revisited later.Screenshots
Testing instructions
New PHPUnit tests cover the
edit_comment()validation (re-parenting, clearing to top-level, and rejecting cross-post, nonexistent, self, child, and descendant parents):tests/phpunit/tests/admin/includes/comment/EditComment_Test.php.Trac ticket: https://core.trac.wordpress.org/ticket/65570
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Fable 5
Used for: Implementation, tests, and screenshots were authored with AI assistance, directed and reviewed by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code