diff --git a/features/option.feature b/features/option.feature index 235bb0e37..d1ea4571c 100644 --- a/features/option.feature +++ b/features/option.feature @@ -57,6 +57,21 @@ Feature: Manage WordPress options When I run `wp option delete str_opt` Then STDOUT should not be empty + When I run `wp option add option_one "ONE"` + And I run `wp option add option_two "TWO"` + Then STDOUT should not be empty + + When I try `wp option delete option_one option_two option_three` + Then STDOUT should be: + """ + Success: Deleted 'option_one' option. + Success: Deleted 'option_two' option. + """ + And STDERR should contain: + """ + Warning: Could not delete 'option_three' option. Does it exist? + """ + When I run `wp option list` Then STDOUT should not contain: """ @@ -227,7 +242,7 @@ Feature: Manage WordPress options When I try `wp option list --search='auto_opt' --autoload` Then STDOUT should not be empty - And STDERR should be: + And STDERR should be: """ Warning: --autoload parameter needs a value """ @@ -235,7 +250,7 @@ Feature: Manage WordPress options When I try `wp option list --search='auto_opt' --autoload=no` Then STDOUT should be empty - And STDERR should be: + And STDERR should be: """ Error: Value of '--autoload' should be on or off. """ @@ -243,7 +258,7 @@ Feature: Manage WordPress options When I try `wp option add str_opt_foo 'bar' --autoload` Then STDOUT should not be empty - And STDERR should be: + And STDERR should be: """ Warning: --autoload parameter needs a value """ @@ -251,7 +266,7 @@ Feature: Manage WordPress options When I try `wp option add str_opt_foo 'bar' --autoload=off` Then STDOUT should be empty - And STDERR should contain: + And STDERR should contain: """ Error: Parameter errors: """ diff --git a/src/Option_Command.php b/src/Option_Command.php index 6ff111286..0514fea0e 100644 --- a/src/Option_Command.php +++ b/src/Option_Command.php @@ -435,7 +435,7 @@ public function update( $args, $assoc_args ) { * * ## OPTIONS * - * + * ... * : Key for the option. * * ## EXAMPLES @@ -443,14 +443,20 @@ public function update( $args, $assoc_args ) { * # Delete an option. * $ wp option delete my_option * Success: Deleted 'my_option' option. + * + * # Delete multiple options + * $ wp option delete option_one option_two option_three + * Success: Deleted 'option_one' option. + * Success: Deleted 'option_two' option. + * Warning: Could not delete 'option_three' option. Does it exist? */ public function delete( $args ) { - list( $key ) = $args; - - if ( !delete_option( $key ) ) { - WP_CLI::error( "Could not delete '$key' option. Does it exist?" ); - } else { - WP_CLI::success( "Deleted '$key' option." ); + foreach ( $args as $arg ) { + if ( ! delete_option( $arg ) ) { + WP_CLI::warning( "Could not delete '$arg' option. Does it exist?" ); + } else { + WP_CLI::success( "Deleted '$arg' option." ); + } } }