Fixed links for terms
This commit is contained in:
parent
ff6970031b
commit
396242b89c
|
@ -504,7 +504,7 @@ abstract class WC_REST_Terms_Controller extends WP_REST_Controller {
|
||||||
protected function prepare_links( $term, $request ) {
|
protected function prepare_links( $term, $request ) {
|
||||||
$base = '/' . $this->namespace . '/' . $this->rest_base;
|
$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 );
|
$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;
|
return $this->taxonomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $request['attribute_id'] ) {
|
if ( ! empty( $request['attribute_id'] ) ) {
|
||||||
$taxonomy = wc_attribute_taxonomy_name_by_id( (int) $request['attribute_id'] );
|
$taxonomy = wc_attribute_taxonomy_name_by_id( (int) $request['attribute_id'] );
|
||||||
|
|
||||||
$this->taxonomy = $taxonomy;
|
$this->taxonomy = $taxonomy;
|
||||||
|
|
|
@ -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';
|
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 obj $item Term object.
|
||||||
* @param WP_REST_Request $request
|
* @param WP_REST_Request $request
|
||||||
|
|
|
@ -77,7 +77,7 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Terms_Controller {
|
||||||
|
|
||||||
$response = rest_ensure_response( $data );
|
$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.
|
* Filter a term item returned from the API.
|
||||||
|
|
|
@ -91,7 +91,7 @@ class WC_REST_Product_Shipping_Classes_Controller extends WC_REST_Terms_Controll
|
||||||
|
|
||||||
$response = rest_ensure_response( $data );
|
$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.
|
* Filter a term item returned from the API.
|
||||||
|
|
|
@ -65,7 +65,7 @@ class WC_REST_Product_Tags_Controller extends WC_REST_Terms_Controller {
|
||||||
|
|
||||||
$response = rest_ensure_response( $data );
|
$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.
|
* Filter a term item returned from the API.
|
||||||
|
|
Loading…
Reference in New Issue