if ( is_array( $comments ) &&
$comments ) { // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
$post_ids =
array_unique( wp_list_pluck( $comments, 'comment_post_ID'
) );
_prime_post_caches( $post_ids,
strpos( get_option( 'permalink_structure'
), '%category%'
), false
);
foreach ( (array) $comments as $comment ) { $output .= '<li class="recentcomments">';
$output .=
sprintf( /* translators: Comments widget. 1: Comment author, 2: Post link. */
_x( '%1$s on %2$s', 'widgets'
),
'<span class="comment-author-link">' .
get_comment_author_link( $comment ) . '</span>',
'<a href="' .
esc_url( get_comment_link( $comment ) ) . '">' .
get_the_title( $comment->comment_post_ID
) . '</a>'
);
$output .= '</li>';
} } $output .= '</ul>';
if ( 'html5' ===
$format ) { $output .= '</nav>';
} $output .=
$args['after_widget'
];