Skip to content
Open
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
13 changes: 13 additions & 0 deletions features/widget.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/Widget_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading