Skip to content

wp widget move --sidebar-id --position puts the widget at the top when the position matches its current index #94

Open

Description

@dhrupo

When a widget moves to another sidebar with --position=<n>, it lands at position 1 instead of <n> if <n> is the same as its position in the current sidebar:

$ wp widget move archives-1 --sidebar-id=sidebar-2 --position=2
$ wp widget list sidebar-2 --fields=id,position

Expected archives-1 at position 2, but the list shows:

id	position
archives-1	1
search-2	2

Widget_Command::move() sets the new index to the current index when --position is not given, and then resets it to 0 for a move to another sidebar if the new index equals the current index. That check cannot tell "no --position" from "--position that happens to match the current index", so the given position is ignored.

Expected: archives-1 is at position 2 in sidebar-2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions