On this page
WP_REST_Menus_Controller::prepare_links( WP_Term $term ): array
Prepares links for the request.
Parameters
$termWP_Term Required-
Term object.
Return
array Links for the given term.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php. View all references
protected function prepare_links( $term ) {
$links = parent::prepare_links( $term );
$locations = $this->get_menu_locations( $term->term_id );
foreach ( $locations as $location ) {
$url = rest_url( sprintf( 'wp/v2/menu-locations/%s', $location ) );
$links['https://api.w.org/menu-location'][] = array(
'href' => $url,
'embeddable' => true,
);
}
return $links;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_REST_Menus_Controller::get_menu_locations() wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php | Returns the names of the locations assigned to the menu. |
| WP_REST_Terms_Controller::prepare_links() wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Prepares links for the request. |
| rest_url() wp-includes/rest-api.php | Retrieves the URL to a REST endpoint. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Menus_Controller::prepare_item_for_response() wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php | Prepares a single term output for response. |
Changelog
| Version | Description |
|---|---|
| 5.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_menus_controller/prepare_links