WordPress at Your Fingertips
function is not described

WC_REST_Terms_Controller::prepare_links() protected WC 1.0

Prepare links for the request.

{} It's a method of the class: WC_REST_Terms_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, $request );
$term(object) (required)
Term object.
$request(WP_REST_Request) (required)
Full details about the request.

Code of WC_REST_Terms_Controller::prepare_links() WC 5.6.0

protected function prepare_links( $term, $request ) {
	$base = '/' . $this->namespace . '/' . $this->rest_base;

	if ( ! empty( $request['attribute_id'] ) ) {
		$base = str_replace( '(?P<attribute_id>[\d]+)', (int) $request['attribute_id'], $base );
	}

	$links = array(
		'self'       => array(
			'href' => rest_url( trailingslashit( $base ) . $term->term_id ),
		),
		'collection' => array(
			'href' => rest_url( $base ),
		),
	);

	if ( $term->parent ) {
		$parent_term = get_term( (int) $term->parent, $term->taxonomy );
		if ( $parent_term ) {
			$links['up'] = array(
				'href' => rest_url( trailingslashit( $base ) . $parent_term->term_id ),
			);
		}
	}

	return $links;
}