Make WordPress Core

Changeset 34461


Ignore:
Timestamp:
09/23/2015 07:48:41 PM (9 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-advanced.php

    r34275 r34461  
    264264do_action( 'dbx_post_advanced', $post );
    265265
    266 if ( post_type_supports($post_type, 'comments') )
    267     add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core');
    268 
    269 if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') )
    270     add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core');
     266// Allow the Discussion meta box to show up if the post type supports comments,
     267// or if comments or pings are open.
     268if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) {
     269    add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core' );
     270}
     271
     272if ( 'publish' === get_post_status( $post ) || 'private' === get_post_status( $post ) ) {
     273    // If the post type support comments, or the post has comments, allow the
     274    // Comments meta box.
     275    if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
     276        add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core' );
     277    }
     278}
    271279
    272280if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )
Note: See TracChangeset for help on using the changeset viewer.