WP_REST_Menu_Locations_Controller::get_items( WP_REST_Request $request ): WP_Error|WP_REST_Response

In this article

Retrieves all menu locations, depending on user context.

Parameters

$requestWP_REST_Requestrequired
Full details about the request.

Return

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

Source

public function get_items( $request ) {
	$data = array();

	foreach ( get_registered_nav_menus() as $name => $description ) {
		$location              = new stdClass();
		$location->name        = $name;
		$location->description = $description;

		$location      = $this->prepare_item_for_response( $location, $request );
		$data[ $name ] = $this->prepare_response_for_collection( $location );
	}

	return rest_ensure_response( $data );
}

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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