Opened 15 years ago
Last modified 2 weeks ago
#19739 new enhancement
Filters to allow comments on draft & trash post_status posts
| Reported by: | cyberhobo | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Comments | Version: | 3.3 |
| Severity: | normal | Keywords: | has-patch needs-unit-tests |
| Cc: | Focuses: |
Description
Attachments (6)
Change History (30)
#1
@
15 years ago
- Keywords has-patch added
My simple solution seems to work for my use case.
#2
@
12 years ago
- Summary Filter to override exit for comments on drafts (comment_on_draft) → Filters to allow comments on draft & trash post_status posts
#3
@
12 years ago
- Keywords needs-docs needs-patch added; dev-feedback has-patch removed
- Milestone Awaiting Review → Future Release
Seems sane. A negative hook name isn't a good idea though because you end up with a double negative to enable the functionality:
add_filter( 'deny_comment_on_trash', '__return_false' );
Better hook names would be allow_comment_on_trash and allow_comment_on_draft.
Needs some hook docs too.
This ticket was mentioned in Slack in #core by chriscct7. View the logs.
12 years ago
#9
@
12 years ago
- Keywords needs-testing added
Needs testing:
- When commenting on trashed or draft posts, is the browser redirect and the permalink in the comment notification emails correct? How does the browser redirect for a trashed post work?
- Do draft posts actually list comments on the front end (in the default themes at least)?
#12
@
11 years ago
- Keywords needs-refresh removed
Refreshed the patch and docs for 4.4.0 consideration.
#13
follow-up:
↓ 14
@
11 years ago
- Keywords 2nd-opinion has-patch added
Expanding on my comment above:
- What's the use case for commenting on a trashed post?
- When commenting on trashed or draft posts, is the browser redirect and the permalink in the comment notification emails correct? How does the browser redirect for a trashed post work?
- Do draft posts actually list comments on the front end (in the default themes at least)?
I like the idea of allowing commenting on draft post, but I'm not convinced that allowing the same on trashed posts has any benefit.
#14
in reply to: ↑ 13
@
11 years ago
Replying to johnbillion:
Expanding on my comment above:
- What's the use case for commenting on a trashed post?
I am unsure here, too. However, if we're allowing commenting on drafts, I suspect disallowing it on trash posts could be considered strange.
- When commenting on trashed or draft posts, is the browser redirect and the permalink in the comment notification emails correct? How does the browser redirect for a trashed post work?
Works the same way as normal for drafts. Trashed posts can't be 'seen' from the front-end (you get a 404) but I suspect it could be possible to comment on them if a user has the post open before it is trashed. Interestingly, if you try to submit a comment on a post that is moved into the trash as you're writing your comment, on comment submission, you get a wsod. This suggests to me that we shouldn't allow comments on trashed posts.
- Do draft posts actually list comments on the front end (in the default themes at least)?
Yes.
I like the idea of allowing commenting on draft post, but I'm not convinced that allowing the same on trashed posts has any benefit.
Happy to adjust the patch to only allow for drafts, not trashed posts. Thoughts?
#15
@
11 years ago
My original motivation was to allow a draft to be discussed by authors and editors before publication. My plans didn't include discussion on a trashed post. It's a bit of a stretch, but I suppose a review system could potentially include discussion of whether a trashed post should be permanently deleted or restored. If adding that option introduces complexity though, I would consider just the ability to comment on drafts an enhancement.
#16
@
10 years ago
What's the status of this ticket? I'm working on a project that would benefit from comment capabilities on draft CPTs.
#17
@
10 years ago
@ethanfsmith same here BTW lets "trash" the comments on trash post idea,
We can introduce a new supports for CPT named internal comments with WC order notes like interface, just an idea.
this will be helpful to sites with multiple editors and want to leave a note to each other about current editing post.
#19
@
10 years ago
- Keywords needs-unit-tests added; early removed
Needs test coverage.
Related: #39650.
#21
@
10 years ago
- Keywords needs-testing needs-refresh removed
19739.6.diff is a refresh since [40128], and also removes the final if statement containing the pre_comment_on_post hook so it always fires.
Still needs tests.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
4 years ago
This ticket was mentioned in PR #13253 on WordPress/wordpress-develop by @sainathpoojary.
2 weeks ago
#23
This PR introduces an allow_comment_on_draft filter to wp_handle_comment_submission().
Currently, comments on draft posts are hard-blocked. This filter allows developers to override this behavior by returning true, enabling use cases like internal editorial workflows and pre-publication discussions. The existing comment_on_draft action is preserved inside the conditional logic so it continues to fire when comments are blocked.
Additionally, the pre_comment_on_post action has been moved outside the final else block so that it fires unconditionally when no error is returned, aligning with the intent of the original patch.
Note: Based on recent Slack discussions, the allow_comment_on_trash filter originally proposed in this ticket has been omitted due to unresolved architectural questions around how comments on trashed posts should interact with wp_trash_post() and wp_untrash_post().
Trac ticket: https://core.trac.wordpress.org/ticket/19739
## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude 4.6 Sonnet
Used for: Edge-case checks, test generation, and assistance with the PR description; implementation and testing were reviewed and verified by me.
#24
@
2 weeks ago
I investigated this issue in light of the Slack discussion. Since there are still unresolved questions and a lack of consensus regarding how comments on trashed posts should behave (especially regarding wp_trash_post() and wp_untrash_post()), I have limited this PR to focus only on drafts.
This PR introduces an allow_comment_on_draft filter to wp_handle_comment_submission() to allow plugins to override the default block for editorial workflows. The pre_comment_on_post action was also moved outside the conditional block so it fires whenever a comment is successfully allowed through.
Feedback would be appreciated.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Added a post id parameter and similar filter for comments on trashed posts.