Ticket #19739: 19739.6.diff
| File 19739.6.diff, 2.9 KB (added by , 9 years ago) |
|---|
-
src/wp-includes/comment.php
2985 2985 } elseif ( 'trash' == $status ) { 2986 2986 2987 2987 /** 2988 * Fires when a comment is attempted on a trashed post.2988 * Whether to allow comments on trashed posts. 2989 2989 * 2990 * @since 2.9.02990 * @since 4.8.0 2991 2991 * 2992 * @param int $comment_post_ID Post ID. 2992 * @param bool $allow Whether to allow comments on trashed posts. Default false. 2993 * @param int $comment_post_ID The post ID for comments to be enabled on. 2993 2994 */ 2994 do_action( 'comment_on_trash', $comment_post_ID );2995 if ( ! apply_filters( 'allow_comment_on_trash', false, $comment_post_ID ) ) { 2995 2996 2996 return new WP_Error( 'comment_on_trash' ); 2997 /** 2998 * Fires when a comment is attempted on a trashed post. 2999 * 3000 * @since 2.9.0 3001 * 3002 * @param int $comment_post_ID Post ID. 3003 */ 3004 do_action( 'comment_on_trash', $comment_post_ID ); 2997 3005 3006 return new WP_Error( 'comment_on_trash' ); 3007 3008 } 3009 2998 3010 } elseif ( ! $status_obj->public && ! $status_obj->private ) { 2999 3011 3000 3012 /** 3001 * Fires when a comment is attempted on a post in draft mode.3013 * Whether to allow comments on draft posts. 3002 3014 * 3003 * @since 1.5.13015 * @since 4.8.0 3004 3016 * 3005 * @param int $comment_post_ID Post ID. 3017 * @param bool $allow Whether to allow comments on draft posts. Default false. 3018 * @param int $comment_post_ID The post ID for comments to be enabled on. 3006 3019 */ 3007 do_action( 'comment_on_draft', $comment_post_ID ); 3008 3009 if ( current_user_can( 'read_post', $comment_post_ID ) ) { 3010 return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 ); 3011 } else { 3012 return new WP_Error( 'comment_on_draft' ); 3020 if ( ! apply_filters( 'allow_comment_on_draft', false, $comment_post_ID ) ) { 3021 3022 /** 3023 * Fires when a comment is attempted on a post in draft mode. 3024 * 3025 * @since 1.5.1 3026 * 3027 * @param int $comment_post_ID Post ID. 3028 */ 3029 do_action( 'comment_on_draft', $comment_post_ID ); 3030 3031 if ( current_user_can( 'read_post', $comment_post_ID ) ) { 3032 return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 ); 3033 } else { 3034 return new WP_Error( 'comment_on_draft' ); 3035 } 3036 3013 3037 } 3014 3038 3015 3039 } elseif ( post_password_required( $comment_post_ID ) ) { … … 3025 3049 3026 3050 return new WP_Error( 'comment_on_password_protected' ); 3027 3051 3028 } else {3052 } 3029 3053 3030 /**3031 * Fires before a comment is posted.3032 *3033 * @since 2.8.03034 *3035 * @param int $comment_post_ID Post ID.3036 */3037 do_action( 'pre_comment_on_post', $comment_post_ID );3054 /** 3055 * Fires before a comment is posted. 3056 * 3057 * @since 2.8.0 3058 * 3059 * @param int $comment_post_ID Post ID. 3060 */ 3061 do_action( 'pre_comment_on_post', $comment_post_ID ); 3038 3062 3039 }3040 3041 3063 // If the user is logged in 3042 3064 $user = wp_get_current_user(); 3043 3065 if ( $user->exists() ) {