wp_insert_term can return an error so handle appropriately in class-wc-product-attribute.php
Fixes #14429
This commit is contained in:
parent
d11337706e
commit
4fcada6fe9
|
@ -77,7 +77,7 @@ class WC_Product_Attribute implements ArrayAccess {
|
||||||
|
|
||||||
if ( ! $term || is_wp_error( $term ) ) {
|
if ( ! $term || is_wp_error( $term ) ) {
|
||||||
$new_term = wp_insert_term( $option, $this->get_name() );
|
$new_term = wp_insert_term( $option, $this->get_name() );
|
||||||
$term = get_term_by( 'id', $new_term['term_id'], $this->get_name() );
|
$term = is_wp_error( $new_term ) ? false : get_term_by( 'id', $new_term['term_id'], $this->get_name() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $term && ! is_wp_error( $term ) ) {
|
if ( $term && ! is_wp_error( $term ) ) {
|
||||||
|
@ -105,7 +105,7 @@ class WC_Product_Attribute implements ArrayAccess {
|
||||||
|
|
||||||
if ( ! $term || is_wp_error( $term ) ) {
|
if ( ! $term || is_wp_error( $term ) ) {
|
||||||
$new_term = wp_insert_term( $option, $this->get_name() );
|
$new_term = wp_insert_term( $option, $this->get_name() );
|
||||||
$term = get_term_by( 'id', $new_term['term_id'], $this->get_name() );
|
$term = is_wp_error( $new_term ) ? false : get_term_by( 'id', $new_term['term_id'], $this->get_name() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $term && ! is_wp_error( $term ) ) {
|
if ( $term && ! is_wp_error( $term ) ) {
|
||||||
|
|
Loading…
Reference in New Issue