diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index dc63e3653f..b6f27a28cb 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -2167,6 +2167,18 @@ function comment_form( $args = array(), $post_id = null ) { if ( null === $post_id ) $post_id = get_the_ID(); + // Exit the function when comments for the post are closed. + if ( ! comments_open( $post_id ) ) { + /** + * Fires after the comment form if comments are closed. + * + * @since 3.0.0 + */ + do_action( 'comment_form_comments_closed' ); + + return; + } + $commenter = wp_get_current_commenter(); $user = wp_get_current_user(); $user_identity = $user->exists() ? $user->display_name : ''; @@ -2252,209 +2264,200 @@ function comment_form( $args = array(), $post_id = null ) { // Ensure that the filtered args contain all required default values. $args = array_merge( $defaults, $args ); - if ( comments_open( $post_id ) ) : ?> + /** + * Fires before the comment form. + * + * @since 3.0.0 + */ + do_action( 'comment_form_before' ); + ?> +