Properly check for old and new slug while updating attributes

Closes #19247
This commit is contained in:
Claudio Sanches 2018-03-12 15:52:26 -03:00
parent 0cc1b78341
commit 6130a222cc
1 changed files with 1 additions and 1 deletions

View File

@ -450,7 +450,7 @@ function wc_create_attribute( $args ) {
} elseif ( wc_check_if_attribute_name_is_reserved( $slug ) ) {
/* translators: %s: attribute slug */
return new WP_Error( 'invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
} elseif ( ( 0 === $id && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) || ( isset( $args['old_slug'] ) && $args['old_slug'] !== $args['slug'] && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) ) {
} elseif ( ( 0 === $id && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) || ( isset( $args['old_slug'] ) && $args['old_slug'] !== $slug && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) ) {
/* translators: %s: attribute slug */
return new WP_Error( 'invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
}