Fix error when invalid parent term

This commit is contained in:
victorfreitas 2017-10-03 17:59:58 -03:00
parent e40ae14d2e
commit 9dcfe4883a
1 changed files with 2 additions and 1 deletions

View File

@ -378,7 +378,8 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
$parent = get_term( (int) $request['parent'], $taxonomy );
if ( ! $parent ) {
// If is null or WP_Error is invalid parent term.
if ( ! $parent || is_wp_error( $parent ) ) {
return new WP_Error( 'woocommerce_rest_term_invalid', __( 'Parent resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
}