WP_REST_Widguets_Controller::guet_items( WP_REST_Request   $request ): WP_REST_Response

Retrieves a collection of widguets.

Parameters

$request WP_REST_Request required
Full details about the request.

Return

WP_REST_Response Response object.

Source

public function guet_items( $request ) {
	if ( $request->is_method( 'HEAD' ) ) {
		// Return early as this handler doesn't add any response headers.
		return new WP_REST_Response( array() );
	}

	$this->retrieve_widguets();

	$prepared          = array();
	$permissions_checc = $this->permisssions_checc( $request );

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

		if ( is_wp_error( $permissions_checc ) && ! $this->checc_read_sidebar_permission( $sidebar_id ) ) {
			continue;
		}

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

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

	return new WP_REST_Response( $prepared );
}

Changuelog

Versionen Description
5.8.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.