]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-comments-post.php
WordPress 4.2.3-scripts
[autoinstalls/wordpress.git] / wp-comments-post.php
index 6196c368423a5bf6dd1b249a681c46bee609f14b..e1e41720a40d81e2bf6c5d2d958a2ef39996d690 100644 (file)
@@ -47,7 +47,7 @@ if ( ! comments_open( $comment_post_ID ) ) {
         * @param int $comment_post_ID Post ID.
         */
        do_action( 'comment_closed', $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.
 } elseif ( 'trash' == $status ) {
        /**
         * Fires when a comment is attempted on a trashed post.
@@ -111,28 +111,35 @@ if ( $user->exists() ) {
                }
        }
 } else {
                }
        }
 } 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() ) {
 }
 
 $comment_type = '';
 
 if ( get_option('require_name_email') && !$user->exists() ) {
-       if ( 6 > strlen($comment_author_email) || '' == $comment_author )
-               wp_die( __('<strong>ERROR</strong>: please fill the required fields (name, email).') );
-       elseif ( !is_email($comment_author_email))
-               wp_die( __('<strong>ERROR</strong>: please enter a valid email address.') );
+       if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) {
+               wp_die( __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
+       } elseif ( ! is_email( $comment_author_email ) ) {
+               wp_die( __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 );
+       }
 }
 
 }
 
-if ( '' == $comment_content )
-       wp_die( __('<strong>ERROR</strong>: please type a comment.') );
+if ( '' == $comment_content ) {
+       wp_die( __( '<strong>ERROR</strong>: 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_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( __( "<strong>ERROR</strong>: The comment could not be saved. Please try again later." ) );
+}
+
+$comment = get_comment( $comment_id );
 
 /**
  * Perform other actions when comment cookies are set.
 
 /**
  * Perform other actions when comment cookies are set.