Spiffier role creation code.

git-svn-id: http://svn.automattic.com/wordpress/trunk@2898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2005-09-20 23:48:28 +00:00
parent 196c1920ed
commit 22fb57c5c6
2 changed files with 91 additions and 96 deletions

View File

@@ -22,7 +22,10 @@ class WP_Roles {
}
}
function add_role($role, $capabilities, $display_name) {
function add_role($role, $display_name, $capabilities = '') {
if ( isset($this->roles[$role]) )
return;
$this->roles[$role] = array('name' => $display_name,
'capabilities' => $capabilities);
update_option($this->role_key, $this->roles);
@@ -41,7 +44,7 @@ class WP_Roles {
update_option($this->role_key, $this->roles);
}
function add_cap($role, $cap, $grant) {
function add_cap($role, $cap, $grant = true) {
$this->roles[$role]['capabilities'][$cap] = $grant;
update_option($this->role_key, $this->roles);
}
@@ -77,7 +80,7 @@ class WP_Role {
$this->capabilities = $capabilities;
}
function add_cap($cap, $grant) {
function add_cap($cap, $grant = true) {
global $wp_roles;
$this->capabilities[$cap] = $grant;