RoleManagementPage.php
1.43 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
<?php namespace MeowCrew\RoleAndCustomerBasedPricing\RoleManagement;
use MeowCrew\RoleAndCustomerBasedPricing\Core\ServiceContainerTrait;
use MeowCrew\RoleAndCustomerBasedPricing\RoleManagement\Actions\DeleteRoleAction;
use MeowCrew\RoleAndCustomerBasedPricing\RoleManagement\Actions\NewRoleAction;
class RoleManagementPage {
use ServiceContainerTrait;
const PAGE_SLUG = 'rcbp_role_management';
/**
* DeleteRoleAction
*
* @var DeleteRoleAction
*/
private $deleteAction;
/**
* NewRoleAction
*
* @var NewRoleAction
*/
private $newRoleAction;
public function __construct() {
add_action( 'admin_menu', array( $this, 'registerPage' ) );
$this->deleteAction = new DeleteRoleAction();
$this->newRoleAction = new NewRoleAction();
}
public function registerPage() {
add_submenu_page(
'users.php',
__( 'Roles Management', 'role-and-customer-based-pricing-for-woocommerce' ),
__( 'Roles Management', 'role-and-customer-based-pricing-for-woocommerce' ),
'manage_options',
self::PAGE_SLUG,
array( $this, 'renderPage' )
);
}
public function renderPage() {
global $wp_roles;
$rolesTable = new RolesTable( array(), $this->deleteAction );
$rolesTable->prepare_items();
$this->getContainer()->getFileManager()->includeTemplate( 'admin/role-management/list.php', array(
'roles' => $wp_roles->roles,
'roles_table' => $rolesTable,
'new_role_action' => $this->newRoleAction
) );
}
}