WP_REST_Menus_Controller::prepare_links()protectedWP 5.9.0

Prepares links for the request.

Метод класса: WP_REST_Menus_Controller{}

Хуков нет.

Возвращает

Массив. Links for the given term.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->prepare_links( $term );
$term(WP_Term) (обязательный)
Term object.

Список изменений

С версии 5.9.0 Введена.

Код WP_REST_Menus_Controller::prepare_links() WP 6.4.3

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