diff --git a/wp-comments-post.php b/wp-comments-post.php index ebf658603d..59dacc2003 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 e7498b3dd6..ffe503d0fa 100644 --- a/wp-includes/class-walker-comment.php +++ b/wp-includes/class-walker-comment.php @@ -181,6 +181,10 @@ class Walker_Comment extends Walker { return; } + if ( 'comment' === $comment->comment_type ) { + add_filter( 'comment_text', array( $this, 'comment_text' ), 40, 2 ); + } + if ( ( 'pingback' === $comment->comment_type || 'trackback' === $comment->comment_type ) && $args['short_ping'] ) { ob_start(); $this->ping( $comment, $depth, $args ); @@ -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, 'comment_text' ), 40, 2 ); + } } /** @@ -244,6 +252,26 @@ class Walker_Comment extends Walker { comment_approved && ! $show_pending_links ) { + return wp_kses( $comment_text, array() ); + } + + return $comment_text; + } + /** * Outputs a single comment. * @@ -264,7 +292,8 @@ 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 { @@ -279,14 +308,19 @@ class Walker_Comment extends Walker {
comment_approved ) : ?> @@ -354,7 +388,8 @@ 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 { @@ -372,11 +407,15 @@ class Walker_Comment extends Walker { } ?> says:' ), - sprintf( '%s', get_comment_author_link( $comment ) ) - ); + $comment_author = get_comment_author_link( $comment ); + if ( '0' == $comment->comment_approved && ! $show_pending_links ) { + $comment_author = get_comment_author( $comment ); + } + printf( + /* translators: %s: Comment author link. */ + __( '%s says:' ), + sprintf( '%s', $comment_author ) + ); ?> @@ -402,18 +441,20 @@ class Walker_Comment extends Walker { 'div-comment', - 'depth' => $depth, - 'max_depth' => $args['max_depth'], - 'before' => '