mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-01 21:21:24 +01:00
Comments: When commenting on a draft post, display a friendly error message if the user can view the post.
This prevents the unhelpful white screen of death when a user who can view the post (eg. preview it) leaves a comment while the post is in draft. Props sagarprajapati, milindmore22, mayurk, swissspidy Fixes #39650 Built from https://develop.svn.wordpress.org/trunk@40128 git-svn-id: http://core.svn.wordpress.org/trunk@40065 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9e095f0791
commit
76f44d242b
@ -3006,7 +3006,11 @@ function wp_handle_comment_submission( $comment_data ) {
|
||||
*/
|
||||
do_action( 'comment_on_draft', $comment_post_ID );
|
||||
|
||||
return new WP_Error( 'comment_on_draft' );
|
||||
if ( current_user_can( 'read_post', $comment_post_ID ) ) {
|
||||
return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 );
|
||||
} else {
|
||||
return new WP_Error( 'comment_on_draft' );
|
||||
}
|
||||
|
||||
} elseif ( post_password_required( $comment_post_ID ) ) {
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.8-alpha-40127';
|
||||
$wp_version = '4.8-alpha-40128';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user