|
@@ 221-228 (lines=8) @@
|
| 218 |
|
* @param string $cap Capability name. |
| 219 |
|
* @param bool $grant Optional, default is true. Whether role is capable of performing capability. |
| 220 |
|
*/ |
| 221 |
|
public function add_cap( $role, $cap, $grant = true ) { |
| 222 |
|
if ( ! isset( $this->roles[$role] ) ) |
| 223 |
|
return; |
| 224 |
|
|
| 225 |
|
$this->roles[$role]['capabilities'][$cap] = $grant; |
| 226 |
|
if ( $this->use_db ) |
| 227 |
|
update_option( $this->role_key, $this->roles ); |
| 228 |
|
} |
| 229 |
|
|
| 230 |
|
/** |
| 231 |
|
* Remove capability from role. |
|
@@ 239-246 (lines=8) @@
|
| 236 |
|
* @param string $role Role name. |
| 237 |
|
* @param string $cap Capability name. |
| 238 |
|
*/ |
| 239 |
|
public function remove_cap( $role, $cap ) { |
| 240 |
|
if ( ! isset( $this->roles[$role] ) ) |
| 241 |
|
return; |
| 242 |
|
|
| 243 |
|
unset( $this->roles[$role]['capabilities'][$cap] ); |
| 244 |
|
if ( $this->use_db ) |
| 245 |
|
update_option( $this->role_key, $this->roles ); |
| 246 |
|
} |
| 247 |
|
|
| 248 |
|
/** |
| 249 |
|
* Retrieve role object by name. |