WP_REST_Menu_Locations_Controller::prepare_links() – Prepares links for the request.
You appear to be a bot. Output may be restricted
Description
Prepares links for the request.
Usage
$array = WP_REST_Menu_Locations_Controller::prepare_links( $location );
Parameters
- $location
- ( stdClass ) required – Menu location.
Returns
array Links for the given menu location.
Source
File name: wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php
Lines:
1 to 29 of 29
protected function prepare_links( $location ) { $base = sprintf( '%s/%s', $this->namespace, $this->rest_base ); // Entity meta. $links = array( 'self' => array( 'href' => rest_url( trailingslashit( $base ) . $location->name ), ), 'collection' => array( 'href' => rest_url( $base ), ), ); $locations = get_nav_menu_locations(); $menu = isset( $locations[ $location->name ] ) ? $locations[ $location->name ] : 0; if ( $menu ) { $path = rest_get_route_for_term( $menu ); if ( $path ) { $url = rest_url( $path ); $links['https://api.w.org/menu'][] = array( 'href' => $url, 'embeddable' => true, ); } } return $links; }