Use 'comments_per_page' option as fallback in get_page_of_comment().

The function now uses the following order of precedence when calculating
comment pagination: 1. the 'per_page' value passed in the `$args` array,
2. the 'comments_per_page' query var in `$wp_query`, and 3. the
'comments_per_page' setting from options-discussion.php. This change allows
`get_page_of_comment()` to return an accurate value before the main query
has been run.

Props laceous.
See #13939.

git-svn-id: https://develop.svn.wordpress.org/trunk@34806 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2015-10-03 19:25:25 +00:00
parent ddc75e22ee
commit 3b89b3ca28
2 changed files with 25 additions and 2 deletions
+9 -2
View File
@@ -855,8 +855,15 @@ function get_page_of_comment( $comment_ID, $args = array() ) {
$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
$args = wp_parse_args( $args, $defaults );
if ( '' === $args['per_page'] )
$args['per_page'] = get_query_var('comments_per_page');
// Order of precedence: 1. `$args['per_page']`, 2. 'comments_per_page' query_var, 3. 'comments_per_page' option.
if ( '' === $args['per_page'] ) {
$args['per_page'] = get_query_var( 'comments_per_page' );
}
if ( '' === $args['per_page'] ) {
$args['per_page'] = get_option( 'comments_per_page' );
}
if ( empty($args['per_page']) ) {
$args['per_page'] = 0;
$args['page'] = 0;