WP_REST_Menus_Controller::prepare_links( WP_Term $term ): array

In this article

Prepares links for the request.

Parameters

$termWP_Termrequired
Term object.

Return

array Links for the given term.

Source

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

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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