--- a/wp/wp-includes/blocks/latest-comments.php Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/blocks/latest-comments.php Wed Sep 21 18:19:35 2022 +0200
@@ -41,8 +41,8 @@
* @return string Returns the post content with latest comments added.
*/
function render_block_core_latest_comments( $attributes = array() ) {
- // This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php.
$comments = get_comments(
+ // This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php.
apply_filters(
'widget_comments_args',
array(
@@ -116,34 +116,28 @@
}
}
- $class = 'wp-block-latest-comments';
- if ( ! empty( $attributes['className'] ) ) {
- $class .= ' ' . $attributes['className'];
- }
- if ( isset( $attributes['align'] ) ) {
- $class .= " align{$attributes['align']}";
- }
+ $classnames = array();
if ( $attributes['displayAvatar'] ) {
- $class .= ' has-avatars';
+ $classnames[] = 'has-avatars';
}
if ( $attributes['displayDate'] ) {
- $class .= ' has-dates';
+ $classnames[] = 'has-dates';
}
if ( $attributes['displayExcerpt'] ) {
- $class .= ' has-excerpts';
+ $classnames[] = 'has-excerpts';
}
if ( empty( $comments ) ) {
- $class .= ' no-comments';
+ $classnames[] = 'no-comments';
}
- $classnames = esc_attr( $class );
+ $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) );
return ! empty( $comments ) ? sprintf(
- '<ol class="%1$s">%2$s</ol>',
- $classnames,
+ '<ol %1$s>%2$s</ol>',
+ $wrapper_attributes,
$list_items_markup
) : sprintf(
- '<div class="%1$s">%2$s</div>',
- $classnames,
+ '<div %1$s>%2$s</div>',
+ $wrapper_attributes,
__( 'No comments to show.' )
);
}