X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/11be8dc178e77d0b46189bbd8e33a216a9b90942..312084b5d95c21feb519ff03decf948420e1f6fa:/wp-comments-post.php diff --git a/wp-comments-post.php b/wp-comments-post.php index 64cc8e32..e60d159d 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -17,7 +17,7 @@ require( dirname(__FILE__) . '/wp-load.php' ); nocache_headers(); -$comment_post_ID = (int) $_POST['comment_post_ID']; +$comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0; $status = $wpdb->get_row( $wpdb->prepare("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) ); @@ -27,9 +27,17 @@ if ( empty($status->comment_status) ) { } elseif ( !comments_open($comment_post_ID) ) { do_action('comment_closed', $comment_post_ID); wp_die( __('Sorry, comments are closed for this item.') ); -} elseif ( in_array($status->post_status, array('draft', 'pending') ) ) { +} elseif ( in_array($status->post_status, array('draft', 'future', 'pending') ) ) { do_action('comment_on_draft', $comment_post_ID); exit; +} elseif ( 'trash' == $status->post_status ) { + do_action('comment_on_trash', $comment_post_ID); + exit; +} elseif ( post_password_required($comment_post_ID) ) { + do_action('comment_on_password_protected', $comment_post_ID); + exit; +} else { + do_action('pre_comment_on_post', $comment_post_ID); } $comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null; @@ -52,7 +60,7 @@ if ( $user->ID ) { } } } else { - if ( get_option('comment_registration') ) + if ( get_option('comment_registration') || 'private' == $status->post_status ) wp_die( __('Sorry, you must be logged in to post a comment.') ); } @@ -76,9 +84,10 @@ $comment_id = wp_new_comment( $commentdata ); $comment = get_comment($comment_id); if ( !$user->ID ) { - setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); - setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); - setcookie('comment_author_url_' . COOKIEHASH, clean_url($comment->comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); + $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000); + setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); + setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); + setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); } $location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;