WC_REST_Products_V2_Controller::prepare_links()protectedWC 1.0

Prepare links for the request.

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

Хуков нет.

Возвращает

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

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->prepare_links( $object, $request );
$object(WC_Data) (обязательный)
Object data.
$request(WP_REST_Request) (обязательный)
Request object.

Код WC_REST_Products_V2_Controller::prepare_links() WC 8.7.0

protected function prepare_links( $object, $request ) {
	$links = array(
		'self'       => array(
			'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ),  // @codingStandardsIgnoreLine.
		),
		'collection' => array(
			'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),  // @codingStandardsIgnoreLine.
		),
	);

	if ( $object->get_parent_id() ) {
		$links['up'] = array(
			'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ),  // @codingStandardsIgnoreLine.
		);
	}

	return $links;
}