src/Widget_Command.php
private function get_sidebar_widgets( $sidebar_id ) {

		$all_widgets = $this->wp_get_sidebars_widgets();

		if ( empty( $all_widgets[ $sidebar_id ] ) ) {
			return array();
		}

		$prepared_widgets = array();
		foreach ( $all_widgets[ $sidebar_id ] as $key => $widget_id ) {

			$prepared_widget = new stdClass();

			$parts        = explode( '-', $widget_id );
			$option_index = array_pop( $parts );
			$widget_name  = implode( '-', $parts );

			$prepared_widget->name     = $widget_name;
			$prepared_widget->id       = $widget_id;
			$prepared_widget->position = $key + 1;
			$widget_options            = get_option( 'widget_' . $widget_name );
			$prepared_widget->options  = $widget_options[ $option_index ];

			$prepared_widgets[] = $prepared_widget;
		}

		return $prepared_widgets;
	}
private function get_sidebar_widgets( $sidebar_id ) {

		$all_widgets = $this->wp_get_sidebars_widgets();

		if ( empty( $all_widgets[ $sidebar_id ] ) ) {
			return array();
		}

		$prepared_widgets = array();
		foreach ( $all_widgets[ $sidebar_id ] as $key => $widget_id ) {

			$prepared_widget = new stdClass();

			$parts        = explode( '-', $widget_id );
			$option_index = array_pop( $parts );
			$widget_name  = implode( '-', $parts );

			$prepared_widget->name     = $widget_name;
			$prepared_widget->id       = $widget_id;
			$prepared_widget->position = $key + 1;
			$widget_options            = get_option( 'widget_' . $widget_name );
			$prepared_widget->options  = $widget_options[ $option_index ];

			$prepared_widgets[] = $prepared_widget;
		}

		return $prepared_widgets;
	}
Gets the widgets (and their associated data) for a given sidebar

@param string $sidebar_id
@return array