Skip to content

Comments: Allow changing a comment's parent from the Edit Comment screen#12406

Open
youknowriad wants to merge 1 commit into
WordPress:trunkfrom
youknowriad:add/65570-edit-comment-parent
Open

Comments: Allow changing a comment's parent from the Edit Comment screen#12406
youknowriad wants to merge 1 commit into
WordPress:trunkfrom
youknowriad:add/65570-edit-comment-parent

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

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() lists comment_parent among its updatable fields, and the REST API accepts parent on update).

This PR adds an editable "In reply to" control to the Edit Comment screen:

  • The "In reply to" line in the Save box is now always displayed (showing "None" for top-level comments), with an Edit toggle following the exact pattern of the "Submitted on" (timestamp) control above it.
  • The picker is a <select> of the other comments on the same post, each option labeled with the comment author and a trimmed excerpt (via get_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 reads comment_parent from the submitted form and validates it before handing off to wp_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 a WP_Error, surfaced the same way as other comment update failures. The quick-edit AJAX path is unaffected, as its form does not submit comment_parent.
  • Without JavaScript, the fieldset is simply visible and submits with the form, same as the timestamp control.

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

Picker open After choosing a parent
Edit Comment Save box with the parent comment select open Edit Comment Save box showing the updated In reply to author

Testing instructions

  1. On a post with a few (threaded) comments, go to Comments and click Edit on one of them.
  2. In the Save box, click Edit next to "In reply to:".
  3. Pick another comment — note the edited comment itself and its own replies are not offered — and click OK, then Update.
  4. Verify the comment is re-parented on the front end.

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

…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>
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props youknowriad.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant