forked from Yoast/wordpress-seo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-role-manager-vip.php
50 lines (45 loc) · 1.16 KB
/
class-role-manager-vip.php
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
<?php
/**
* @package WPSEO\Admin\Roles
*/
/**
* VIP implementation of the Role Manager.
*/
final class WPSEO_Role_Manager_VIP extends WPSEO_Abstract_Role_Manager {
/**
* Adds a role to the system.
*
* @param string $role Role to add.
* @param string $display_name Name to display for the role.
* @param array $capabilities Capabilities to add to the role.
*
* @return void
*/
protected function add_role( $role, $display_name, array $capabilities = array() ) {
$enabled_capabilities = array();
$disabled_capabilities = array();
// Build lists of enabled and disabled capabilities.
foreach ( $capabilities as $capability => $grant ) {
if ( $grant ) {
$enabled_capabilities[] = $capability;
}
if ( ! $grant ) {
$disabled_capabilities[] = $capability;
}
}
wpcom_vip_add_role( $role, $display_name, $enabled_capabilities );
if ( $disabled_capabilities !== array() ) {
wpcom_vip_remove_role_caps( $role, $disabled_capabilities );
}
}
/**
* Removes a role from the system.
*
* @param string $role Role to remove.
*
* @return void
*/
protected function remove_role( $role ) {
remove_role( $role );
}
}