public function move( $args, $assoc_args ) {

		list( $widget_id ) = $args;
		if ( ! $this->validate_sidebar_widget( $widget_id ) ) {
			WP_CLI::error( "Widget doesn't exist." );
		}

		if ( empty( $assoc_args['position'] ) && empty( $assoc_args['sidebar-id'] ) ) {
			WP_CLI::error( 'A new position or new sidebar must be specified.' );
		}

		list( $name, $option_index, $current_sidebar_id, $current_sidebar_index ) = $this->get_widget_data( $widget_id );

		$new_sidebar_id = ! empty( $assoc_args['sidebar-id'] ) ? $assoc_args['sidebar-id'] : $current_sidebar_id;
		$this->validate_sidebar( $new_sidebar_id );

		$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 ) {
			// Human-readable positions are different than numerically indexed array
			$new_sidebar_index = 0;
		}

		$this->move_sidebar_widget( $widget_id, $current_sidebar_id, $new_sidebar_id, $current_sidebar_index, $new_sidebar_index );

		WP_CLI::success( 'Widget moved.' );

	}
public function move( $args, $assoc_args ) {

		list( $widget_id ) = $args;
		if ( ! $this->validate_sidebar_widget( $widget_id ) ) {
			WP_CLI::error( "Widget doesn't exist." );
		}

		if ( empty( $assoc_args['position'] ) && empty( $assoc_args['sidebar-id'] ) ) {
			WP_CLI::error( 'A new position or new sidebar must be specified.' );
		}

		list( $name, $option_index, $current_sidebar_id, $current_sidebar_index ) = $this->get_widget_data( $widget_id );

		$new_sidebar_id = ! empty( $assoc_args['sidebar-id'] ) ? $assoc_args['sidebar-id'] : $current_sidebar_id;
		$this->validate_sidebar( $new_sidebar_id );

		$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 ) {
			// Human-readable positions are different than numerically indexed array
			$new_sidebar_index = 0;
		}

		$this->move_sidebar_widget( $widget_id, $current_sidebar_id, $new_sidebar_id, $current_sidebar_index, $new_sidebar_index );

		WP_CLI::success( 'Widget moved.' );

	}
public function move ( $ args , $ assoc_args ) { list ( $ widget_id ) = $ args ; if ( ! $ this -> validate_sidebar_widget ( $ widget_id ) ) { WP_CLI :: error ( "Widget doesn't exist." ) ; } if ( empty ( $ assoc_args [ 'position' ] ) && empty ( $ assoc_args [ 'sidebar-id' ] ) ) { WP_CLI :: error ( 'A new position or new sidebar must be specified.' ) ; } list ( $ name , $ option_index , $ current_sidebar_id , $ current_sidebar_index ) = $ this -> get_widget_data ( $ widget_id ) ; $ new_sidebar_id = ! empty ( $ assoc_args [ 'sidebar-id' ] ) ? $ assoc_args [ 'sidebar-id' ] : $ current_sidebar_id ; $ this -> validate_sidebar ( $ new_sidebar_id ) ; $ 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 ) { // Human-readable positions are different than numerically indexed array $ new_sidebar_index = 0 ; } $ this -> move_sidebar_widget ( $ widget_id , $ current_sidebar_id , $ new_sidebar_id , $ current_sidebar_index , $ new_sidebar_index ) ; WP_CLI :: success ( 'Widget moved.' ) ; }
Moves the position of a widget.

Changes the order of a widget in its existing sidebar, or moves it to a
new sidebar.

## OPTIONS

<widget-id>
: Unique ID for the widget

[--position=<position>]
: Assign the widget to a new position.

[--sidebar-id=<sidebar-id>]
: Assign the widget to a new sidebar

## EXAMPLES

# Change position of widget
$ wp widget move recent-comments-2 --position=2
Success: Widget moved.

# Move widget to Inactive Widgets
$ wp widget move recent-comments-2 --sidebar-id=wp_inactive_widgets
Success: Widget moved.

@subcommand move
Moves the position of a widget .