From c2dbc0c8873fb4701591fa69ec3ee24a36a4f86a Mon Sep 17 00:00:00 2001 From: Gerhard Potgieter Date: Fri, 4 May 2018 08:50:14 +0200 Subject: [PATCH] Keep taxonomy_hierarchical test in place --- includes/abstracts/abstract-wc-rest-terms-controller.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/abstracts/abstract-wc-rest-terms-controller.php b/includes/abstracts/abstract-wc-rest-terms-controller.php index 82698856d3d..8d5cdd7ae29 100644 --- a/includes/abstracts/abstract-wc-rest-terms-controller.php +++ b/includes/abstracts/abstract-wc-rest-terms-controller.php @@ -381,6 +381,9 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller { $args['slug'] = $request['slug']; } if ( isset( $request['parent'] ) ) { + if ( ! is_taxonomy_hierarchical( $taxonomy ) ) { + return new WP_Error( 'woocommerce_rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.', 'woocommerce' ), array( 'status' => 400 ) ); + } $args['parent'] = $request['parent']; } @@ -475,6 +478,9 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller { $prepared_args['slug'] = $request['slug']; } if ( isset( $request['parent'] ) ) { + if ( ! is_taxonomy_hierarchical( $taxonomy ) ) { + return new WP_Error( 'woocommerce_rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.', 'woocommerce' ), array( 'status' => 400 ) ); + } $prepared_args['parent'] = $request['parent']; }