@@ 229-236 (lines=8) @@ | ||
226 | * @param string $cap Capability name. |
|
227 | * @param bool $grant Optional, default is true. Whether role is capable of performing capability. |
|
228 | */ |
|
229 | public function add_cap( $role, $cap, $grant = true ) { |
|
230 | if ( ! isset( $this->roles[$role] ) ) |
|
231 | return; |
|
232 | ||
233 | $this->roles[$role]['capabilities'][$cap] = $grant; |
|
234 | if ( $this->use_db ) |
|
235 | update_option( $this->role_key, $this->roles ); |
|
236 | } |
|
237 | ||
238 | /** |
|
239 | * Remove capability from role. |
|
@@ 247-254 (lines=8) @@ | ||
244 | * @param string $role Role name. |
|
245 | * @param string $cap Capability name. |
|
246 | */ |
|
247 | public function remove_cap( $role, $cap ) { |
|
248 | if ( ! isset( $this->roles[$role] ) ) |
|
249 | return; |
|
250 | ||
251 | unset( $this->roles[$role]['capabilities'][$cap] ); |
|
252 | if ( $this->use_db ) |
|
253 | update_option( $this->role_key, $this->roles ); |
|
254 | } |
|
255 | ||
256 | /** |
|
257 | * Retrieve role object by name. |