Fixed links for terms

This commit is contained in:
Claudio Sanches 2016-03-07 17:28:52 -03:00
parent ff6970031b
commit 396242b89c
5 changed files with 6 additions and 6 deletions

View File

@ -504,7 +504,7 @@ abstract class WC_REST_Terms_Controller extends WP_REST_Controller {
protected function prepare_links( $term, $request ) {
$base = '/' . $this->namespace . '/' . $this->rest_base;
if ( $request['attribute_id'] ) {
if ( ! empty( $request['attribute_id'] ) ) {
$base = str_replace( '(?P<attribute_id>[\d]+)', (int) $request['attribute_id'], $base );
}
@ -715,7 +715,7 @@ abstract class WC_REST_Terms_Controller extends WP_REST_Controller {
return $this->taxonomy;
}
if ( $request['attribute_id'] ) {
if ( ! empty( $request['attribute_id'] ) ) {
$taxonomy = wc_attribute_taxonomy_name_by_id( (int) $request['attribute_id'] );
$this->taxonomy = $taxonomy;

View File

@ -37,7 +37,7 @@ class WC_REST_Product_Attribute_Terms_Controller extends WC_REST_Terms_Controlle
protected $rest_base = 'products/attributes/(?P<attribute_id>[\d]+)/terms';
/**
* Prepare a single product tag output for response.
* Prepare a single product attribute term output for response.
*
* @param obj $item Term object.
* @param WP_REST_Request $request

View File

@ -77,7 +77,7 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Terms_Controller {
$response = rest_ensure_response( $data );
$response->add_links( $this->prepare_links( $item ) );
$response->add_links( $this->prepare_links( $item, $request ) );
/**
* Filter a term item returned from the API.

View File

@ -91,7 +91,7 @@ class WC_REST_Product_Shipping_Classes_Controller extends WC_REST_Terms_Controll
$response = rest_ensure_response( $data );
$response->add_links( $this->prepare_links( $item ) );
$response->add_links( $this->prepare_links( $item, $request ) );
/**
* Filter a term item returned from the API.

View File

@ -65,7 +65,7 @@ class WC_REST_Product_Tags_Controller extends WC_REST_Terms_Controller {
$response = rest_ensure_response( $data );
$response->add_links( $this->prepare_links( $item ) );
$response->add_links( $this->prepare_links( $item, $request ) );
/**
* Filter a term item returned from the API.