WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 10 months ago

#19739 new enhancement

Filters to allow comments on draft & trash post_status posts

Reported by: cyberhobo Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.3
Component: Comments Keywords: 2nd-opinion has-patch
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 (5)

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

Download all attachments as: .zip

Change History (20)

@cyberhobo
5 years ago

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

#1 @cyberhobo
5 years ago

  • Keywords has-patch added

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

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

#2 @chriscct7
21 months 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
21 months 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
21 months ago

Second patch

#4 @chriscct7
21 months ago

@johnbillion Does that work?

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


21 months ago

@chriscct7
21 months ago

Move action inside per slack chat

@chriscct7
21 months ago

4th patch version

#6 @chriscct7
21 months ago

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

@johnbillion Ready to go

#7 @johnbillion
21 months ago

  • Milestone changed from Future Release to 4.1

#8 @johnbillion
21 months ago

#30091 was marked as a duplicate.

#9 @johnbillion
21 months 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
21 months ago

  • Milestone changed from 4.1 to Future Release

#11 @wonderboymusic
10 months ago

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

@iamfriendly
10 months ago

Refreshed the patch and docs for 4.4.0

#12 @iamfriendly
10 months ago

  • Keywords needs-refresh removed

Refreshed the patch and docs for 4.4.0 consideration.

#13 follow-up: @johnbillion
10 months 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
10 months 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
10 months 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.

Note: See TracTickets for help on using tickets.