WP_REST_Menus_Controller::prepare_links()protectedWP 5.9.0

Prepares links for the request.

{} It's a method of the class: WP_REST_Menus_Controller{}

No Hooks.

Return

Array. Links for the given term.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_links( $term );
$term(WP_Term) (required)
Term object.

Changelog

Since 5.9.0 Introduced.

Code of WP_REST_Menus_Controller::prepare_links() WP 6.0

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