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.

git-svn-id: https://develop.svn.wordpress.org/trunk@34531 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2015-09-25 04:25:20 +00:00
parent 7757f84a69
commit 039955d5cd
2 changed files with 26 additions and 4 deletions

View File

@@ -459,7 +459,7 @@ class Tests_User_Query extends WP_UnitTestCase {
// All values get reset
$query->prepare_query( array( 'number' => 8 ) );
$this->assertNotEmpty( $query->query_limit );
$this->assertEquals( 'LIMIT 8', $query->query_limit );
$this->assertEquals( 'LIMIT 0, 8', $query->query_limit );
// All values get reset
$query->prepare_query( array( 'fields' => 'all' ) );
@@ -857,4 +857,21 @@ class Tests_User_Query extends WP_UnitTestCase {
$this->assertEqualSets( $expected, $found );
}
/**
* @ticket 25145
*/
public function test_paged() {
$users = $this->factory->user->create_many( 5 );
$q = new WP_User_Query( array(
'number' => 2,
'paged' => 2,
'orderby' => 'ID',
'order' => 'DESC', // Avoid funkiness with user 1.
'fields' => 'ids',
) );
$this->assertEquals( array( $users[2], $users[1] ), $q->results );
}
}