From 652a3030e1453460755400e0084f226ccefc2aba Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 23 Sep 2015 19:49:26 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@34461 git-svn-id: http://core.svn.wordpress.org/trunk@34425 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 16 ++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 145a4d7081..2f8b7743c3 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -263,11 +263,19 @@ if ( post_type_supports($post_type, 'custom-fields') ) */ do_action( 'dbx_post_advanced', $post ); -if ( post_type_supports($post_type, 'comments') ) - add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core'); +// Allow the Discussion meta box to show up if the post type supports comments, +// or if comments or pings are open. +if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) { + add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core' ); +} -if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') ) - add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core'); +if ( 'publish' === get_post_status( $post ) || 'private' === get_post_status( $post ) ) { + // If the post type support comments, or the post has comments, allow the + // Comments meta box. + if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) { + add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core' ); + } +} if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); diff --git a/wp-includes/version.php b/wp-includes/version.php index 24af754281..31a921da17 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34460'; +$wp_version = '4.4-alpha-34461'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.