mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-09 18:08:09 +01:00
Capabilities fixes from the O man. fixes #1561
git-svn-id: http://svn.automattic.com/wordpress/trunk@2793 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c58b95fe37
commit
3627bffe0e
@ -64,7 +64,7 @@ class WP_Roles {
|
|||||||
|
|
||||||
function is_role($role)
|
function is_role($role)
|
||||||
{
|
{
|
||||||
return empty($this->role_names[$role]);
|
return isset($this->role_names[$role]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,11 +132,11 @@ class WP_User {
|
|||||||
global $wp_roles;
|
global $wp_roles;
|
||||||
//Filter out caps that are not role names and assign to $this->roles
|
//Filter out caps that are not role names and assign to $this->roles
|
||||||
if(is_array($this->caps))
|
if(is_array($this->caps))
|
||||||
$this->roles = array_filter($this->caps, array(&$wp_roles, 'is_role'));
|
$this->roles = array_filter(array_keys($this->caps), array(&$wp_roles, 'is_role'));
|
||||||
|
|
||||||
//Build $allcaps from role caps, overlay user's $caps
|
//Build $allcaps from role caps, overlay user's $caps
|
||||||
$this->allcaps = array();
|
$this->allcaps = array();
|
||||||
foreach($this->roles as $role => $value) {
|
foreach($this->roles as $role) {
|
||||||
$role = $wp_roles->get_role($role);
|
$role = $wp_roles->get_role($role);
|
||||||
$this->allcaps = array_merge($this->allcaps, $role->capabilities);
|
$this->allcaps = array_merge($this->allcaps, $role->capabilities);
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ class WP_User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function set_role($role) {
|
function set_role($role) {
|
||||||
foreach($this->roles as $oldrole => $value)
|
foreach($this->roles as $oldrole)
|
||||||
unset($this->caps[$oldrole]);
|
unset($this->caps[$oldrole]);
|
||||||
$this->caps[$role] = true;
|
$this->caps[$role] = true;
|
||||||
$this->roles = array($role => true);
|
$this->roles = array($role => true);
|
||||||
|
Loading…
Reference in New Issue
Block a user