WC_REST_Orders_V2_Controller::prepare_links()
Prepare links for the request.
Метод класса: WC_REST_Orders_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_Orders_V2_Controller::prepare_links() WC REST Orders V2 Controller::prepare links WC 7.7.2
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() ) ), ), 'collection' => array( 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), ), ); if ( 0 !== (int) $object->get_customer_id() ) { $links['customer'] = array( 'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $object->get_customer_id() ) ), ); } if ( 0 !== (int) $object->get_parent_id() ) { $links['up'] = array( 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $object->get_parent_id() ) ), ); } return $links; }