WordPress at Your Fingertips
function is not described

WP_REST_Widgets_Controller::get_items() public WP 5.8.0

Retrieves a collection of widgets.

{} It's a method of the class: WP_REST_Widgets_Controller{}

No Hooks.

Return

WP_REST_Response|WP_Error. Response object on success, or WP_Error object on failure.

Usage

$WP_REST_Widgets_Controller = new WP_REST_Widgets_Controller();
$WP_REST_Widgets_Controller->get_items( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Changelog

Since 5.8.0 Introduced.

Code of WP_REST_Widgets_Controller::get_items() WP 5.8.1

public function get_items( $request ) {
	retrieve_widgets();

	$prepared = array();

	foreach ( wp_get_sidebars_widgets() as $sidebar_id => $widget_ids ) {
		if ( isset( $request['sidebar'] ) && $sidebar_id !== $request['sidebar'] ) {
			continue;
		}

		foreach ( $widget_ids as $widget_id ) {
			$response = $this->prepare_item_for_response( compact( 'sidebar_id', 'widget_id' ), $request );

			if ( ! is_wp_error( $response ) ) {
				$prepared[] = $this->prepare_response_for_collection( $response );
			}
		}
	}

	return new WP_REST_Response( $prepared );
}