mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00: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 git-svn-id: https://develop.svn.wordpress.org/trunk@40128 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3005,8 +3005,12 @@ function wp_handle_comment_submission( $comment_data ) {
|
||||
* @param int $comment_post_ID Post ID.
|
||||
*/
|
||||
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 ) ) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user