Group.php
1.01 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
<?php
namespace ACA\BP\Helper\Select\Entities;
use AC;
use ACA\BP\Helper\Select;
use BP_Groups_Group;
use WP_Query;
class Group extends AC\Helper\Select\Entities
implements AC\Helper\Select\Paginated {
/** @var int */
private $per_page;
/**
* @var WP_Query
*/
protected $query;
public function __construct( array $args = [], AC\Helper\Select\Value $value = null ) {
if ( null === $value ) {
$value = new Select\Value\Group();
}
$args = array_merge( [
'type' => 'alphabetical',
'per_page' => 20,
'page' => 1,
'show_hidden' => true,
], $args );
$this->per_page = $args['per_page'];
$items = BP_Groups_Group::get( $args );
$this->query = $items;
parent::__construct( $items['groups'], $value );
}
public function get_total_pages() {
return ceil( $this->query['total'] / $this->per_page );
}
public function get_page() {
return filter_input( INPUT_POST, 'page' );
}
public function is_last_page() {
return $this->get_total_pages() <= $this->get_page();
}
}