Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion features/cap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: Manage Cap
Success: Added 1 capability to 'contributor' role.
"""

When I run `wp cap add contributor behold observe`
When I run `wp cap add contributor behold observe --grant`
Then STDOUT should contain:
"""
Success: Added 2 capabilities to 'contributor' role.
Expand All @@ -38,6 +38,12 @@ Feature: Manage Cap
Success: Added 2 capabilities to 'contributor' role as false.
"""

When I run `wp cap add contributor inspire --grant=false`
Then STDOUT should contain:
"""
Success: Added 1 capability to 'contributor' role as false.
"""

When I run `wp cap list contributor`
Then STDOUT should contain:
"""
Expand Down
5 changes: 4 additions & 1 deletion src/Capabilities_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ public function add( $args, $assoc_args ) {

$role_obj = self::get_role( $role );

$grant = ! isset( $assoc_args['grant'] ) || ! empty( $assoc_args['grant'] );
$grant = true;
if ( isset( $assoc_args['grant'] ) ) {
$grant = ! $assoc_args['grant'] || 'false' === $assoc_args['grant'] ? false : true;
}

$count = 0;

Expand Down