Make WordPress Core

Opened 13 years ago

Last modified 2 years ago

#19739 new enhancement

Filters to allow comments on draft & trash post_status posts

Reported by: cyberhobo's profile cyberhobo Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.3
Component: Comments Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

I'd like to use comments on draft posts as part of an editorial workflow. Will this be as easy as adding a filter to fire before the current comment_on_draft action that can be checked before exiting? I'll try that and add a patch if it looks good.

Related #13276. Not relevant to #18630, I think.

Attachments (6)

19739.diff (769 bytes) - added by cyberhobo 13 years ago.
Added a post id parameter and similar filter for comments on trashed posts.
19739.2.diff (1.2 KB) - added by chriscct7 10 years ago.
Second patch
19739.3.diff (1.3 KB) - added by chriscct7 10 years ago.
Move action inside per slack chat
19739.4.diff (1.7 KB) - added by chriscct7 10 years ago.
4th patch version
19739.5.diff (2.1 KB) - added by iamfriendly 9 years ago.
Refreshed the patch and docs for 4.4.0
19739.6.diff (2.9 KB) - added by johnbillion 8 years ago.

Download all attachments as: .zip

Change History (28)

@cyberhobo
13 years ago

Added a post id parameter and similar filter for comments on trashed posts.

#1 @cyberhobo
13 years ago

  • Keywords has-patch added

My simple solution works for my use case, and seems pretty low impact. How bout it?

Last edited 13 years ago by cyberhobo (previous) (diff)

#2 @chriscct7
10 years ago

  • Summary changed from Filter to override exit for comments on drafts (comment_on_draft) to Filters to allow comments on draft & trash post_status posts

#3 @johnbillion
10 years ago

  • Keywords needs-docs needs-patch added; dev-feedback has-patch removed
  • Milestone changed from Awaiting Review to 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.

@chriscct7
10 years ago

Second patch

#4 @chriscct7
10 years ago

@johnbillion Does that work?

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


10 years ago

@chriscct7
10 years ago

Move action inside per slack chat

@chriscct7
10 years ago

4th patch version

#6 @chriscct7
10 years ago

  • Keywords has-patch added; needs-docs needs-patch removed

@johnbillion Ready to go

#7 @johnbillion
10 years ago

  • Milestone changed from Future Release to 4.1

#8 @johnbillion
10 years ago

#30091 was marked as a duplicate.

#9 @johnbillion
10 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)?

#10 @johnbillion
10 years ago

  • Milestone changed from 4.1 to Future Release

#11 @wonderboymusic
10 years ago

  • Keywords needs-refresh added; has-patch needs-testing removed

@iamfriendly
9 years ago

Refreshed the patch and docs for 4.4.0

#12 @iamfriendly
9 years ago

  • Keywords needs-refresh removed

Refreshed the patch and docs for 4.4.0 consideration.

#13 follow-up: @johnbillion
9 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 @iamfriendly
9 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 @cyberhobo
9 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 @ethanfsmith
8 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 @milindmore22
8 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.

Last edited 8 years ago by milindmore22 (previous) (diff)

#18 @johnbillion
8 years ago

  • Keywords needs-testing early added; 2nd-opinion removed

#19 @johnbillion
8 years ago

  • Keywords needs-unit-tests added; early removed

Needs test coverage.

Related: #39650.

#20 @johnbillion
8 years ago

  • Keywords needs-refresh added

@johnbillion
8 years ago

#21 @johnbillion
8 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.


2 years ago

Note: See TracTickets for help on using tickets.