Improved links

This commit is contained in:
Claudio Sanches 2018-07-24 15:56:46 -03:00
parent 7d07d52279
commit 1137782c6a
1 changed files with 13 additions and 3 deletions

View File

@ -432,11 +432,21 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
'collection' => array( 'collection' => array(
'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
), ),
'product' => array(
'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $review->comment_post_ID ) ),
),
); );
if ( 0 !== (int) $review->comment_post_ID ) {
$links['up'] = array(
'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $review->comment_post_ID ) ),
);
}
if ( 0 !== (int) $review->user_id ) {
$links['reviewer'] = array(
'href' => rest_url( 'wp/v2/users/' . $review->user_id ),
'embeddable' => true,
);
}
return $links; return $links;
} }