WP_REST_Menu_Locations_Controller::get_items() WordPress Method
The WP_REST_Menu_Locations_Controller::get_items() method is used to get a list of registered menu locations for a given theme.
WP_REST_Menu_Locations_Controller::get_items( WP_REST_Request $request ) #
Retrieves all menu locations, depending on user context.
Parameters
- $request
(WP_REST_Request)(Required)Full details about the request.
Return
(WP_Error|WP_REST_Response) Response object on success, or WP_Error object on failure.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php
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 ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |