Make WordPress Core

Opened 12 years ago

Closed 9 years ago

#24486 closed defect (bug) (fixed)

The 'commentsdiv' meta box isn't displayed when using custom post statuses

Reported by: xyntaman's profile XyntaMan Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 2.8
Component: Comments Keywords: has-patch
Focuses: administration Cc:

Description

The 'commentsdiv' meta box, which shows comments to a post in the admin post edit section (and also gives the ability to post additional comments straight from there) isn't displayed when the post is set to any non-publish or non-private post status, particularly any custom post status.

As far as I can tell, the problem arises from the fact that the said meta box is initialized in "wp-admin/edit-form-advanced.php", where the conditional expression for its initialization has the "publish" and "private" post statuses hardcoded in:

if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )
	add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');

The existing code is disabling the initialization of the 'commentsdiv' meta box in any use case with custom post statuses, reducing their usefulness and flexibility.

In my opinion, the the simplest fix for this would be to remove the post status check as a condition for the 'commentsdiv' meta box initialization, leaving the "post_type_supports($post_type, 'comments')" as the only condition:

if ( post_type_supports($post_type, 'comments') )
	add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');

Attachments (3)

commentsdiv.24486.diff (793 bytes) - added by XyntaMan 12 years ago.
Fix for the bug
24486.diff (1.2 KB) - added by Thaicloud 10 years ago.
Include custom public post statuses in check
24486.2.diff (1.2 KB) - added by Thaicloud 10 years ago.

Download all attachments as: .zip

Change History (13)

@XyntaMan
12 years ago

Fix for the bug

#1 @XyntaMan
12 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
12 years ago

  • Version changed from 3.5.1 to 2.8

Introduced in [10480].

#3 @jeremyfelt
11 years ago

  • Component changed from Administration to Comments
  • Focuses admin added

#4 follow-up: @rachelbaker
10 years ago

  • Milestone changed from Awaiting Review to 4.2

Instead of removing the post_status check, we should check that any custom post statuses are public.

@Thaicloud
10 years ago

Include custom public post statuses in check

#5 in reply to: ↑ 4 @Thaicloud
10 years ago

  • Keywords needs-testing added

Replying to rachelbaker:

Instead of removing the post_status check, we should check that any custom post statuses are public.

Added a patch that uses the get_post_stati() function to return all public statuses, with the fallback being only the public status. I've tested with some custom statuses (stati?) and it works for me.

@Thaicloud
10 years ago

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


10 years ago

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


10 years ago

#8 @DrewAPicture
10 years ago

  • Milestone changed from 4.2 to Future Release

Hi @Thaicloud, on 24486.2.diff, I'd suggest probably just including the 'private' status in the fallback array if $stati is empty, therefore removing the need for the 'private' condition.

We're going to punt this to a future release as this can currently be worked around by adding the meta box yourself.

Last edited 10 years ago by DrewAPicture (previous) (diff)

#9 @wonderboymusic
9 years ago

  • Keywords needs-testing removed
  • Milestone changed from Future Release to 4.4

#10 @wonderboymusic
9 years ago

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

In 34515:

Edit Post: in the logic determining whether to display the Comments meta box, check for the current post status in get_post_stati( array( 'public' => true ) ) instead of just checking publish and private. Ensure that private is checked in both instances.

Props Thaicloud, wonderboymusic.
Fixes #24486.

Note: See TracTickets for help on using tickets.