diff --git a/wp-comments-post.php b/wp-comments-post.php index fe03cb7296..a3ea760c62 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -56,8 +56,8 @@ do_action( 'set_comment_cookies', $comment, $user, $cookies_consent ); $location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID; -// Add specific query arguments to display the awaiting moderation message. -if ( 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) { +// If user didn't consent to cookies, add specific query arguments to display the awaiting moderation message. +if ( ! $cookies_consent && 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) { $location = add_query_arg( array( 'unapproved' => $comment->comment_ID, diff --git a/wp-includes/class-walker-comment.php b/wp-includes/class-walker-comment.php index 87834f52be..8fe85fb0c2 100644 --- a/wp-includes/class-walker-comment.php +++ b/wp-includes/class-walker-comment.php @@ -181,7 +181,11 @@ class Walker_Comment extends Walker { return; } - if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) { + if ( 'comment' === $comment->comment_type ) { + add_filter( 'comment_text', array( $this, 'filter_comment_text' ), 40, 2 ); + } + + if ( ( 'pingback' === $comment->comment_type || 'trackback' === $comment->comment_type ) && $args['short_ping'] ) { ob_start(); $this->ping( $comment, $depth, $args ); $output .= ob_get_clean(); @@ -194,6 +198,10 @@ class Walker_Comment extends Walker { $this->comment( $comment, $depth, $args ); $output .= ob_get_clean(); } + + if ( 'comment' === $comment->comment_type ) { + remove_filter( 'comment_text', array( $this, 'filter_comment_text' ), 40, 2 ); + } } /** @@ -244,6 +252,29 @@ class Walker_Comment extends Walker { comment_approved && ! $show_pending_links ) { + $comment_text = wp_kses( $comment_text, array() ); + } + + return $comment_text; + } + /** * Outputs a single comment. * @@ -264,13 +295,14 @@ class Walker_Comment extends Walker { $add_below = 'div-comment'; } - $commenter = wp_get_current_commenter(); + $commenter = wp_get_current_commenter(); + $show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author']; + if ( $commenter['comment_author_email'] ) { $moderation_note = __( 'Your comment is awaiting moderation.' ); } else { $moderation_note = __( 'Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.' ); } - ?> < has_children ? 'parent' : '', $comment ); ?> id="comment-"> @@ -279,14 +311,21 @@ class Walker_Comment extends Walker {
comment_approved ) : ?> @@ -354,13 +393,14 @@ class Walker_Comment extends Walker { protected function html5_comment( $comment, $depth, $args ) { $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; - $commenter = wp_get_current_commenter(); + $commenter = wp_get_current_commenter(); + $show_pending_links = ! empty( $commenter['comment_author'] ); + if ( $commenter['comment_author_email'] ) { $moderation_note = __( 'Your comment is awaiting moderation.' ); } else { $moderation_note = __( 'Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.' ); } - ?> < id="comment-" has_children ? 'parent' : '', $comment ); ?>>