Make WordPress Core


Ignore:
Timestamp:
09/25/2015 04:25:20 AM (9 years ago)
Author:
boonebgorges
Message:

Introduce 'paged' parameter for WP_User_Query.

This is an alternative to using 'offset', and manually calculating pagination.
Note that 'paged' works only in conjunction with 'number', the latter of which
provides the per-page value.

Props sebastian.pisula.
Fixes #25145.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-user-query.php

    r34393 r34531  
    8484     *              for `$orderby` parameter.
    8585     * @since 4.3.0 Added 'has_published_posts' parameter.
     86     * @since 4.4.0 Added 'paged' parameter.
    8687     * @access public
    8788     *
     
    125126     *                                             conjunction with pagination. Value -1 (all) is not supported.
    126127     *                                             Default empty (all users).
     128     *     @type int          $paged               When used with number, defines the page of results to return.
     129     *                                             Default 1.
    127130     *     @type bool         $count_total         Whether to count the total number of users found. If pagination
    128131     *                                             is not needed, setting this to false can improve performance.
     
    158161                'offset' => '',
    159162                'number' => '',
     163                'paged' => 1,
    160164                'count_total' => true,
    161165                'fields' => 'all',
     
    324328        // limit
    325329        if ( isset( $qv['number'] ) && $qv['number'] ) {
    326             if ( $qv['offset'] )
     330            if ( $qv['offset'] ) {
    327331                $this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
    328             else
    329                 $this->query_limit = $wpdb->prepare("LIMIT %d", $qv['number']);
     332            } else {
     333                $this->query_limit = $wpdb->prepare( "LIMIT %d, %d", $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] );
     334            }
    330335        }
    331336
Note: See TracChangeset for help on using the changeset viewer.