Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment template: Call comment_class() before recursing into child comments #40455

Merged
merged 5 commits into from
Apr 20, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Standards-compliant multiline comment
  • Loading branch information
ockham committed Apr 20, 2022
commit 72d708f28a607c7b8403242752d3508e4f1f0248
14 changes: 8 additions & 6 deletions packages/block-library/src/comment-template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ function block_core_comment_template_render_comments( $comments, $block ) {

$children = $comment->get_children();

// We need to create the CSS classes BEFORE recursing into the children.
// This is because comment_class() uses globals like
// `$comment_alt` and `$comment_thread_alt` which are order-sensitive.
//
// The `false` parameter at the end means that we do NOT want the function to `echo` the output but to return a string.
// See https://developer.wordpress.org/reference/functions/comment_class/#parameters.
/*
* We need to create the CSS classes BEFORE recursing into the children.
* This is because comment_class() uses globals like
* `$comment_alt` and `$comment_thread_alt` which are order-sensitive.
*
* The `false` parameter at the end means that we do NOT want the function to `echo` the output but to return a string.
* See https://developer.wordpress.org/reference/functions/comment_class/#parameters.
*/
$comment_classes = comment_class( '', $comment->comment_ID, $comment->comment_post_ID, false );

// If the comment has children, recurse to create the HTML for the nested
Expand Down