WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#28080 closed defect (bug) (fixed)

Commenting possible on custom post type after support for commenting removed from CPT.

Reported by: Shelob9 Owned by: couturefreak
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.9
Component: Comments Keywords: has-patch commit
Focuses: Cc:
PR Number:

Description

I have found that if a custom post type is created with support for comments, and post in that CPT exist, when removing support for comments from the CPT, it is still possible to post comments on existing posts in the CPT. Since the CPT no longer supports comments, there are no discussion controls available in the post editor so discussion can not be manually disabled for the posts created before support for comments was removed from the CPT.

I am testing with trunk (4.0 alpha) and Twenty Fourteen.

Attachments (4)

28080.patch (4.1 KB) - added by couturefreak 5 years ago.
Enables comment meta boxes for posts that have comments already.
28080.2.patch (4.1 KB) - added by couturefreak 5 years ago.
Enables comment meta boxes for posts that have comments enabled and/or actual comments.
28080.diff (1.6 KB) - added by wonderboymusic 4 years ago.
28080.3.patch (1.6 KB) - added by rachelbaker 4 years ago.
Minor refresh. Strictly checks the post_status string and adds missing period to inline comment

Download all attachments as: .zip

Change History (18)

#1 @SergeyBiryukov
6 years ago

  • Component changed from General to Comments

Related: #12991, #27111.

#2 @helen
5 years ago

  • Version changed from trunk to 3.9

@couturefreak
5 years ago

Enables comment meta boxes for posts that have comments already.

@couturefreak
5 years ago

Enables comment meta boxes for posts that have comments enabled and/or actual comments.

#3 @couturefreak
5 years ago

I was able to reproduce this.

Simply removing custom post type support for comments does not mean that comments are disabled for a post. I believe that is the correct logic. In some cases, an admin may want to keep the existing comments on those posts, even if comments are eventually disabled for the entire post type ( or if they use a plugin to convert the post type to another post type ) .

Currently: Post comment meta boxes ( discussion and comments ) are only visible based on the check for post_type_supports() for comments.

The patch above adds a check for comments_open() or pings_open() to show the discussion meta box.
And adds an additional check for comment_count > 0 to show the comments meta box.

So, if a post has comments or pings enabled, the admin will still be able to disable comments / pings using the post_comment_status_meta_box(), and moderate existing comments on the post using the post_comment_meta_box(), even if the post type no longer supports comments.

#4 @rachelbaker
5 years ago

  • Keywords has-patch needs-testing added

#5 @couturefreak
5 years ago

Notes:
Check for post_type_supports(), and if disabled, remove discussion box, and disable comments on front-end.
Check for existing comments and display comments meta box.

#6 @DrewAPicture
5 years ago

  • Keywords good-first-bug added
  • Milestone changed from Awaiting Review to 4.2
  • Owner set to couturefreak
  • Status changed from new to assigned

#7 @helen
5 years ago

Related in terms of post_type_supports(): #31168.

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


5 years ago

#9 @DrewAPicture
5 years ago

  • Milestone changed from 4.2 to Future Release

Thinking we should wait to make a decision here until #31168 gets sorted out, though the logic in comment:5 seems sane to me. Punting to future release.

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


5 years ago

@wonderboymusic
4 years ago

#11 @wonderboymusic
4 years ago

  • Milestone changed from Future Release to 4.4

28080.diff is a refresh, let's see what is up here now that #31168 is sorted

@rachelbaker
4 years ago

Minor refresh. Strictly checks the post_status string and adds missing period to inline comment

#12 @rachelbaker
4 years ago

  • Keywords commit added; needs-testing good-first-bug removed

Tested @wonderboymusic's patch and it looks good to me. I refreshed it with a few minor changes.

+1

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

#13 @wonderboymusic
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34461:

Comments: allow meta boxes for Discussion and Comments in extenuating circumstances.

  • Discussion: Post Type stops supporting comments, but comments and/or pings are open on a post.
  • Comments: Post is published or private, the post type has stopped supporting comments, but comments and/or pings are open on a post.

Currently, there is no way to toggle those settings off.

Props couturefreak, wonderboymusic, rachelbaker.
Fixes #28080.

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


4 years ago

Note: See TracTickets for help on using tickets.