From 5c0d7292f30a6fdbbd85fd2736d9f9cb375fe6e5 Mon Sep 17 00:00:00 2001 From: Khan M Rashedun-Naby Date: Tue, 15 May 2018 15:44:32 +0600 Subject: [PATCH] wc_get_object_terms refactored --- includes/wc-term-functions.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/includes/wc-term-functions.php b/includes/wc-term-functions.php index a2bcecc3a1d..5b1caf08a2c 100644 --- a/includes/wc-term-functions.php +++ b/includes/wc-term-functions.php @@ -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. $terms = get_the_terms( $object_id, $taxonomy ); - if ( $terms && ! is_wp_error( $terms ) ) { - if ( ! is_null( $field ) ) { - $terms = wp_list_pluck( $terms, $field, $index_key ); - } - } else { - $terms = array(); + if ( ! $terms || is_wp_error( $terms ) || is_null( $field ) ) { + return array(); } - return $terms; + return wp_list_pluck( $terms, $field, $index_key ); } /**