web/wp-comments-post.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
    15 /** Sets up the WordPress Environment. */
    15 /** Sets up the WordPress Environment. */
    16 require( dirname(__FILE__) . '/wp-load.php' );
    16 require( dirname(__FILE__) . '/wp-load.php' );
    17 
    17 
    18 nocache_headers();
    18 nocache_headers();
    19 
    19 
    20 $comment_post_ID = (int) $_POST['comment_post_ID'];
    20 $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
    21 
    21 
    22 $status = $wpdb->get_row( $wpdb->prepare("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );
    22 $status = $wpdb->get_row( $wpdb->prepare("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );
    23 
    23 
    24 if ( empty($status->comment_status) ) {
    24 if ( empty($status->comment_status) ) {
    25 	do_action('comment_id_not_found', $comment_post_ID);
    25 	do_action('comment_id_not_found', $comment_post_ID);
    27 } elseif ( !comments_open($comment_post_ID) ) {
    27 } elseif ( !comments_open($comment_post_ID) ) {
    28 	do_action('comment_closed', $comment_post_ID);
    28 	do_action('comment_closed', $comment_post_ID);
    29 	wp_die( __('Sorry, comments are closed for this item.') );
    29 	wp_die( __('Sorry, comments are closed for this item.') );
    30 } elseif ( in_array($status->post_status, array('draft', 'pending') ) ) {
    30 } elseif ( in_array($status->post_status, array('draft', 'pending') ) ) {
    31 	do_action('comment_on_draft', $comment_post_ID);
    31 	do_action('comment_on_draft', $comment_post_ID);
       
    32 	exit;
       
    33 } elseif ( 'trash' == $status->post_status ) {
       
    34 	do_action('comment_on_trash', $comment_post_ID);
    32 	exit;
    35 	exit;
    33 } else {
    36 } else {
    34 	do_action('pre_comment_on_post', $comment_post_ID);
    37 	do_action('pre_comment_on_post', $comment_post_ID);
    35 }
    38 }
    36 
    39