Comments: Update the "Mine" count after AJAX moderation and reply actions. - #13040
Comments: Update the "Mine" count after AJAX moderation and reply actions.#13040ikamal7 wants to merge 1 commit into
Conversation
…ions. The comments list table updates the All, Approved, Pending, Spam, and Trash counts via AJAX, but the Mine count never changed because the moderation/reply responses did not indicate whether the affected comment belonged to the current user. Adds an isCurrentUserComment flag to the AJAX supplemental data and uses it in edit-comments.js to keep the Mine count in sync. Props itzmekhokan, peterwilsoncc, arkaprabhachowdhury. Fixes #46017
|
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. |
Summary
isCurrentUserCommentflag to thesupplementaldata returned by_wp_ajax_delete_comment_response()(used by bothwp_ajax_delete_comment()for trash/untrash/spam/unspam/delete, andwp_ajax_dim_comment()for approve/unapprove).edit-comments.jsuses that flag to bumpspan.mine-countby the same delta as Pending/Approved when the affected comment belongs to the current user, and unconditionally bumps it by 1 after a reply is added (a reply is always authored by the current user).Why
"Mine" (
class-wp-comments-list-table.php) counts comments wherecomment->user_id === get_current_user_id(), independent of moderation. Approve/Unapprove alone never changes this count since Mine already includes both pending and approved comments; only entering/leaving Spam/Trash does — which is what the JS change reflects.Fixes https://core.trac.wordpress.org/ticket/46017
Testing
php -lon the touched PHP file.node --checkon the touched JS file.Test plan
/wp-admin/edit-comments.phpas a user who has authored comments.