fixed bug where woocommerce_create_term would return notice Trying to get property of non-object if $term was null
This commit is contained in:
parent
251bbe75d1
commit
7dc04f5a2f
|
@ -316,17 +316,22 @@ function woocommerce_create_term( $term_id, $tt_id, $taxonomy ) {
|
||||||
|
|
||||||
$term = get_term($term_id, $taxonomy);
|
$term = get_term($term_id, $taxonomy);
|
||||||
|
|
||||||
// gets the sibling terms
|
if ( $term != null ){
|
||||||
$siblings = get_terms($taxonomy, "parent={$term->parent}&menu_order=ASC&hide_empty=0");
|
|
||||||
|
// gets the sibling terms
|
||||||
foreach ($siblings as $sibling) {
|
$siblings = get_terms($taxonomy, "parent={$term->parent}&menu_order=ASC&hide_empty=0");
|
||||||
if( $sibling->term_id == $term_id ) continue;
|
|
||||||
$next_id = $sibling->term_id; // first sibling term of the hierarchy level
|
foreach ($siblings as $sibling) {
|
||||||
break;
|
if( $sibling->term_id == $term_id ) continue;
|
||||||
|
$next_id = $sibling->term_id; // first sibling term of the hierarchy level
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// reorder
|
||||||
|
woocommerce_order_terms( $term, $next_id, $taxonomy );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reorder
|
|
||||||
woocommerce_order_terms( $term, $next_id, $taxonomy );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue