Prime post caches for the Recent Comments widget. props mitchoyoshitaka. see #15400.
git-svn-id: https://develop.svn.wordpress.org/trunk@22278 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
abda77ed10
commit
ffa6fd2e62
@ -686,6 +686,10 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
||||
|
||||
$output .= '<ul id="recentcomments">';
|
||||
if ( $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">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user