Comments: Add a filter for top level comments query arguments in `comments_template()`.
Props hellofromTonya, Howdy_McGee, garrett-eclipse, davidbaumwald, thomaslhotta. Fixes #38074. Built from https://develop.svn.wordpress.org/trunk@49256 git-svn-id: http://core.svn.wordpress.org/trunk@49018 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5b4d643d60
commit
fbd8078d4e
|
@ -1434,6 +1434,24 @@ function comments_template( $file = '/comments.php', $separate_comments = false
|
||||||
$top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
|
$top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the arguments used in the top level comments query.
|
||||||
|
*
|
||||||
|
* @since 5.6.0
|
||||||
|
*
|
||||||
|
* @see WP_Comment_Query::__construct()
|
||||||
|
*
|
||||||
|
* @param array $top_level_args {
|
||||||
|
* The top level query arguments for the comments template.
|
||||||
|
*
|
||||||
|
* @type bool $count Whether to return a comment count.
|
||||||
|
* @type string|array $orderby The field(s) to order by.
|
||||||
|
* @type int $post_id The post ID.
|
||||||
|
* @type string|array $status The comment status to limit results by.
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
$top_level_args = apply_filters( 'comments_template_top_level_query_args', $top_level_args );
|
||||||
|
|
||||||
$top_level_count = $top_level_query->query( $top_level_args );
|
$top_level_count = $top_level_query->query( $top_level_args );
|
||||||
|
|
||||||
$comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page;
|
$comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page;
|
||||||
|
@ -1464,6 +1482,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
|
$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
|
||||||
|
|
||||||
$comment_query = new WP_Comment_Query( $comment_args );
|
$comment_query = new WP_Comment_Query( $comment_args );
|
||||||
$_comments = $comment_query->comments;
|
$_comments = $comment_query->comments;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.6-alpha-49255';
|
$wp_version = '5.6-alpha-49256';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue