mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Improve lazyloading of comment meta in WP_Query loops.
Lazy-loading logic is moved to a method on `WP_Query`. This makes it possible for comment feeds to take advantage of metadata lazyloading, in addition to comments loaded via `comments_template()`. This new technique parallels the termmeta lazyloading technique introduced in [34704]. Fixes #34047. git-svn-id: https://develop.svn.wordpress.org/trunk@34711 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1320,6 +1320,10 @@ function comments_template( $file = '/comments.php', $separate_comments = false
|
||||
* @param int $post_ID Post ID.
|
||||
*/
|
||||
$wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID );
|
||||
|
||||
// Set up lazy-loading for comment metadata.
|
||||
add_action( 'get_comment_metadata', array( $wp_query, 'lazyload_comment_meta' ), 10, 2 );
|
||||
|
||||
$comments = &$wp_query->comments;
|
||||
$wp_query->comment_count = count($wp_query->comments);
|
||||
$wp_query->max_num_comment_pages = $comment_query->max_num_pages;
|
||||
|
||||
Reference in New Issue
Block a user