Make WordPress Core


Ignore:
Timestamp:
10/03/2015 07:25:25 PM (9 years ago)
Author:
boonebgorges
Message:

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,

  1. 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-functions.php

    r34805 r34806  
    856856    $args = wp_parse_args( $args, $defaults );
    857857
    858     if ( '' === $args['per_page'] )
    859         $args['per_page'] = get_query_var('comments_per_page');
     858    // Order of precedence: 1. `$args['per_page']`, 2. 'comments_per_page' query_var, 3. 'comments_per_page' option.
     859    if ( '' === $args['per_page'] ) {
     860        $args['per_page'] = get_query_var( 'comments_per_page' );
     861    }
     862
     863    if ( '' === $args['per_page'] ) {
     864        $args['per_page'] = get_option( 'comments_per_page' );
     865    }
     866
    860867    if ( empty($args['per_page']) ) {
    861868        $args['per_page'] = 0;
Note: See TracChangeset for help on using the changeset viewer.