-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclass-user-query.php
More file actions
72 lines (64 loc) · 1.22 KB
/
Copy pathclass-user-query.php
File metadata and controls
72 lines (64 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Post Collection User Query
*
* This wraps \WP_User_Query to generate instances of User.
*
* @package Post_Collection
*/
namespace PostCollection;
defined( 'ABSPATH' ) || exit;
/**
* User_Query class for the Post Collection plugin.
*
* @since 3.0
*
* @package Post_Collection
* @author Alex Kirk
*/
class User_Query extends \WP_User_Query {
/**
* Whether to cache the retrieved users.
*
* @var boolean
*/
public static $cache = true;
/**
* List of found User objects.
*
* @var array
*/
private $results = array();
/**
* Total number of found users for the current query.
*
* @var int
*/
private $total_users = 0;
/**
* Execute the query and ensure that we populate User objects.
*/
public function query() {
parent::query();
foreach ( parent::get_results() as $k => $user ) {
$this->results[ $k ] = new User( $user );
$this->total_users += 1;
}
}
/**
* Return the user results.
*
* @return array Array of User objects.
*/
public function get_results() {
return $this->results;
}
/**
* Returns the total number of users for the current query.
*
* @return int Number of total users.
*/
public function get_total() {
return $this->total_users;
}
}