diff --git a/features/cap.feature b/features/cap.feature index ffb72ae1..96eeb629 100644 --- a/features/cap.feature +++ b/features/cap.feature @@ -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. @@ -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: """ diff --git a/src/Capabilities_Command.php b/src/Capabilities_Command.php index 52d7e53b..c3163596 100644 --- a/src/Capabilities_Command.php +++ b/src/Capabilities_Command.php @@ -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;