WP_REST_Menus_Controller::prepare_links() WordPress Method

The WP_REST_Menus_Controller::prepare_links() method is used to prepare links for the rest of the menu. This includes links for the front page, for the posts page, and for the logout page.

WP_REST_Menus_Controller::prepare_links( WP_Term $term ) #

Prepares links for the request.


Parameters

$term

(WP_Term)(Required)Term object.


Top ↑

Return

(array) Links for the given term.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php

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


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.