diff --git a/features/widget.feature b/features/widget.feature index 1d368c4d..6f0ebe35 100644 --- a/features/widget.feature +++ b/features/widget.feature @@ -110,6 +110,19 @@ Feature: Manage widgets in WordPress sidebar | name | position | options | | archives | 2 | {"title":"New Archives","count":0,"dropdown":0} | + Scenario: Move a widget to a position in another sidebar + When I run `wp widget move archives-1 --sidebar-id=sidebar-2 --position=2` + Then STDOUT should be: + """ + Success: Widget moved. + """ + + When I run `wp widget list sidebar-2 --fields=id,position` + Then STDOUT should be a table containing rows: + | id | position | + | search-2 | 1 | + | archives-1 | 2 | + Scenario: Patch widget options When I run `wp widget patch update archives-1 title "Patched Archives"` Then STDOUT should be: diff --git a/src/Widget_Command.php b/src/Widget_Command.php index c92b9c43..a7f87a2e 100644 --- a/src/Widget_Command.php +++ b/src/Widget_Command.php @@ -361,7 +361,7 @@ public function move( $args, $assoc_args ) { $new_sidebar_index = ! empty( $assoc_args['position'] ) ? $assoc_args['position'] - 1 : $current_sidebar_index; // Moving between sidebars adds to the top. - if ( $new_sidebar_id !== $current_sidebar_id && $new_sidebar_index === $current_sidebar_index ) { + if ( $new_sidebar_id !== $current_sidebar_id && empty( $assoc_args['position'] ) ) { // Human-readable positions are different than numerically indexed array. $new_sidebar_index = 0; }