Keep taxonomy_hierarchical test in place

This commit is contained in:
Gerhard Potgieter 2018-05-04 08:50:14 +02:00
parent a43ac9acae
commit c2dbc0c887
1 changed files with 6 additions and 0 deletions

View File

@ -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'];
}