wc_get_object_terms refactored
This commit is contained in:
parent
6c1234668a
commit
5c0d7292f3
|
@ -25,15 +25,11 @@ function wc_get_object_terms( $object_id, $taxonomy, $field = null, $index_key =
|
||||||
// Test if terms exists. get_the_terms() return false when it finds no terms.
|
// Test if terms exists. get_the_terms() return false when it finds no terms.
|
||||||
$terms = get_the_terms( $object_id, $taxonomy );
|
$terms = get_the_terms( $object_id, $taxonomy );
|
||||||
|
|
||||||
if ( $terms && ! is_wp_error( $terms ) ) {
|
if ( ! $terms || is_wp_error( $terms ) || is_null( $field ) ) {
|
||||||
if ( ! is_null( $field ) ) {
|
return array();
|
||||||
$terms = wp_list_pluck( $terms, $field, $index_key );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$terms = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $terms;
|
return wp_list_pluck( $terms, $field, $index_key );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue