diff --git a/includes/abstracts/abstract-wc-rest-terms-controller.php b/includes/abstracts/abstract-wc-rest-terms-controller.php index 6b1e5844a3e..27f917bb486 100644 --- a/includes/abstracts/abstract-wc-rest-terms-controller.php +++ b/includes/abstracts/abstract-wc-rest-terms-controller.php @@ -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[\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; diff --git a/includes/api/wc-rest-product-attribute-terms-controller.php b/includes/api/wc-rest-product-attribute-terms-controller.php index 20ddd8771e4..2f603893fed 100644 --- a/includes/api/wc-rest-product-attribute-terms-controller.php +++ b/includes/api/wc-rest-product-attribute-terms-controller.php @@ -37,7 +37,7 @@ class WC_REST_Product_Attribute_Terms_Controller extends WC_REST_Terms_Controlle protected $rest_base = 'products/attributes/(?P[\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 diff --git a/includes/api/wc-rest-product-categories-controller.php b/includes/api/wc-rest-product-categories-controller.php index 65d19df34ff..ccb78ccfa06 100644 --- a/includes/api/wc-rest-product-categories-controller.php +++ b/includes/api/wc-rest-product-categories-controller.php @@ -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. diff --git a/includes/api/wc-rest-product-shipping-classes-controller.php b/includes/api/wc-rest-product-shipping-classes-controller.php index 56da0749bc1..a35430a8194 100644 --- a/includes/api/wc-rest-product-shipping-classes-controller.php +++ b/includes/api/wc-rest-product-shipping-classes-controller.php @@ -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. diff --git a/includes/api/wc-rest-product-tags-controller.php b/includes/api/wc-rest-product-tags-controller.php index 7c8e14f39a3..9096e0be867 100644 --- a/includes/api/wc-rest-product-tags-controller.php +++ b/includes/api/wc-rest-product-tags-controller.php @@ -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.