X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/41578db67d72562346e4dbb2a14889b23d522813..af50974463450c98503e763a7836a50e260461a9:/wp-comments-post.php diff --git a/wp-comments-post.php b/wp-comments-post.php index 6196c368..b1612d2f 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -47,7 +47,7 @@ if ( ! comments_open( $comment_post_ID ) ) { * @param int $comment_post_ID Post ID. */ do_action( 'comment_closed', $comment_post_ID ); - wp_die( __('Sorry, comments are closed for this item.') ); + wp_die( __( 'Sorry, comments are closed for this item.' ), 403 ); } elseif ( 'trash' == $status ) { /** * Fires when a comment is attempted on a trashed post. @@ -111,28 +111,35 @@ if ( $user->exists() ) { } } } else { - if ( get_option('comment_registration') || 'private' == $status ) - wp_die( __('Sorry, you must be logged in to post a comment.') ); + if ( get_option( 'comment_registration' ) || 'private' == $status ) { + wp_die( __( 'Sorry, you must be logged in to post a comment.' ), 403 ); + } } $comment_type = ''; if ( get_option('require_name_email') && !$user->exists() ) { - if ( 6 > strlen($comment_author_email) || '' == $comment_author ) - wp_die( __('ERROR: please fill the required fields (name, email).') ); - elseif ( !is_email($comment_author_email)) - wp_die( __('ERROR: please enter a valid email address.') ); + if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) { + wp_die( __( 'ERROR: please fill the required fields (name, email).' ), 200 ); + } else if ( ! is_email( $comment_author_email ) ) { + wp_die( __( 'ERROR: please enter a valid email address.' ), 200 ); + } } -if ( '' == $comment_content ) - wp_die( __('ERROR: please type a comment.') ); +if ( '' == $comment_content ) { + wp_die( __( 'ERROR: please type a comment.' ), 200 ); +} $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0; $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); $comment_id = wp_new_comment( $commentdata ); -$comment = get_comment($comment_id); +if ( ! $comment_id ) { + wp_die( __( "ERROR: The comment could not be saved. Please try again later." ) ); +} + +$comment = get_comment( $comment_id ); /** * Perform other actions when comment cookies are set.