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

Retrieves all menu locations, depending on user context.


Parameters

$request WP_REST_Request Required
Full details about the request.

Top ↑

Return

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


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php. View all references

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 );
}


Top ↑

Changelog

Changelog
Version Description
5.9.0 Introduced.

Top ↑

User Contributed Notes

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