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. Built from https://develop.svn.wordpress.org/trunk@34531 git-svn-id: http://core.svn.wordpress.org/trunk@34495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
563d70aa0d
commit
37e4c2dbac
|
@ -83,6 +83,7 @@ class WP_User_Query {
|
||||||
* @since 4.2.0 Added 'meta_value_num' support for `$orderby` parameter. Added multi-dimensional array syntax
|
* @since 4.2.0 Added 'meta_value_num' support for `$orderby` parameter. Added multi-dimensional array syntax
|
||||||
* for `$orderby` parameter.
|
* for `$orderby` parameter.
|
||||||
* @since 4.3.0 Added 'has_published_posts' parameter.
|
* @since 4.3.0 Added 'has_published_posts' parameter.
|
||||||
|
* @since 4.4.0 Added 'paged' parameter.
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
* @global wpdb $wpdb
|
* @global wpdb $wpdb
|
||||||
|
@ -124,6 +125,8 @@ class WP_User_Query {
|
||||||
* @type int $number Number of users to limit the query for. Can be used in
|
* @type int $number Number of users to limit the query for. Can be used in
|
||||||
* conjunction with pagination. Value -1 (all) is not supported.
|
* conjunction with pagination. Value -1 (all) is not supported.
|
||||||
* Default empty (all users).
|
* Default empty (all users).
|
||||||
|
* @type int $paged When used with number, defines the page of results to return.
|
||||||
|
* Default 1.
|
||||||
* @type bool $count_total Whether to count the total number of users found. If pagination
|
* @type bool $count_total Whether to count the total number of users found. If pagination
|
||||||
* is not needed, setting this to false can improve performance.
|
* is not needed, setting this to false can improve performance.
|
||||||
* Default true.
|
* Default true.
|
||||||
|
@ -157,6 +160,7 @@ class WP_User_Query {
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
'offset' => '',
|
'offset' => '',
|
||||||
'number' => '',
|
'number' => '',
|
||||||
|
'paged' => 1,
|
||||||
'count_total' => true,
|
'count_total' => true,
|
||||||
'fields' => 'all',
|
'fields' => 'all',
|
||||||
'who' => '',
|
'who' => '',
|
||||||
|
@ -323,10 +327,11 @@ class WP_User_Query {
|
||||||
|
|
||||||
// limit
|
// limit
|
||||||
if ( isset( $qv['number'] ) && $qv['number'] ) {
|
if ( isset( $qv['number'] ) && $qv['number'] ) {
|
||||||
if ( $qv['offset'] )
|
if ( $qv['offset'] ) {
|
||||||
$this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
|
$this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
|
||||||
else
|
} else {
|
||||||
$this->query_limit = $wpdb->prepare("LIMIT %d", $qv['number']);
|
$this->query_limit = $wpdb->prepare( "LIMIT %d, %d", $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$search = '';
|
$search = '';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34530';
|
$wp_version = '4.4-alpha-34531';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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