WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 2 years ago

#13473 reopened defect (bug)

comment_status should be set to default_comment_status when commentstatusdiv is removed

Reported by: jimmcq Owned by: westi
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Comments Keywords: needs-patch
Focuses: Cc:

Description

When the Comment Status box is removed from the Add/Edit Post screens, posts should be created with the comment_status set to the value of the default_comment_status option.


I had hidden the Comment Status box via:
remove_meta_box('commentstatusdiv','post','normal');

and made sure that default_comment_status was set to open:
update_option('default_comment_status', 'open');

After adding a new post it displayed "Comments Off" when I was assuming that it should have honored the value of default_comment_status.

Attachments (2)

13473.patch (771 bytes) - added by SergeyBiryukov 3 years ago.
13473.diff (921 bytes) - added by solarissmoke 3 years ago.
Check whether post type supports comments/pings before setting it to default

Download all attachments as: .zip

Change History (18)

comment:1 ryan4 years ago

I'm sure there are similar issues with other meta boxes too. Removing the boxes is not well defined. It can be argued that if the box is removed entirely the status should be off.

comment:2 jimmcq4 years ago

In a multi-site setup, I was trying to simplify the dashboard by removing some extra metaboxes. It just seemed logical to me that the default_comment_status would be honored even that metabox wasn't shown.

I was hoping that removing the box would mean that comments would be on for every post, and that the users wouldn't be able to turn them off. Is there another way to easily accomplish this?

(Yeah, I know I could probably catch a hook when the post is published as modify the comment_status then, but it just seems like extra unnecessary hoops to jump through)

comment:3 nacin4 years ago

I've tried the same thing before. I'd tend to agree that removing the meta box should keep the defaults, not set them all to false.

comment:4 nacin3 years ago

  • Keywords needs-patch added; comments removed
  • Milestone changed from Awaiting Review to Future Release

comment:5 ryno2673 years ago

  • Cc chuck@… added

Have same issue... bug... noticed while back but figured it was something else, but now it's really annoying due to a plugin I made removing commentstatusdiv. needs-patch.

SergeyBiryukov3 years ago

comment:6 SergeyBiryukov3 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Future Release to 3.3

comment:7 solarissmoke3 years ago

  • Cc solaris.smoke@… added

comment:8 solarissmoke3 years ago

I think we should be checking whether the post type supports comments before setting the comment status to default_comment_status, and if it doesn't, set it to closed.

I'm thinking in particular of older themes which don't use post_type_supports() in their comment handling code. They could get confused if comments are open on a post type that doesn't support comments.

solarissmoke3 years ago

Check whether post type supports comments/pings before setting it to default

comment:9 ocean902 years ago

  • Milestone changed from 3.3 to Future Release

This doesn't get much attention. We should review it again in 3.4 and check also the other metaboxes like ryan mentioned.

comment:10 nacin2 years ago

  • Keywords commit added
  • Milestone changed from Future Release to 3.3

I thought I would prefer 13473.patch over 13473.diff, but the latter is more flexible. And it makes sense: If there should be a UI but it is removed, assume the default; otherwise, assume the existing. Suggesting commit.

comment:11 westi2 years ago

  • Owner set to westi
  • Resolution set to fixed
  • Status changed from new to closed

In [19372]:

Respect the default comment/ping status for new posts even when someone has hidden the meta box which lets you alter them on a per-post basis.
Fixes #13473 props solarissmoke.

comment:12 nacin2 years ago

This broke because checkboxes aren't sent when unchecked. #19349

comment:13 nacin2 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Okay, so, the trick here would be to include a hidden input that is always sent from the Discussion box. If it is set, then the box is there and things are unchecked. If it is not set, then the meta box is not there, and we can assume that we need to use the default.

However, if someone unregisters the discussion meta box to register their own with these two checkboxes (piggybacking on what WordPress saves by default is not unheard of for other meta boxes), this will fail to work.

As this is not a regression and is only obtainable by unregistering the meta box in code, I'm going to revert.

comment:14 nacin2 years ago

In [19448]:

Revert [19372] for 3.3. see #13473.

comment:15 nacin2 years ago

  • Milestone changed from 3.3 to Future Release

comment:16 linuxologos2 years ago

  • Cc linuxologos@… added
  • Keywords needs-patch added; has-patch commit removed
Note: See TracTickets for help on using tickets.