/** * Get the array of objects terms * * @param $type A type of term to display * * @return $terms mixed|array * * @since 1.3.1 */ function yit_get_terms($case, $taxonomy) { $exclude = apply_filters('yith_wcan_exclude_terms', array()); switch ($case) { case 'all': $terms = get_terms($taxonomy, array('hide_empty' => true, 'exclude' => $exclude)); break; case 'hierarchical': $terms = yit_reorder_terms_by_parent(get_terms($taxonomy, array('hide_empty' => true, 'exclude' => $exclude))); break; case 'parent': $terms = get_terms($taxonomy, array('hide_empty' => true, 'parent' => false, 'exclude' => $exclude)); break; default: $terms = get_terms($taxonomy, array('hide_empty' => true, 'exclude' => $exclude)); break; } return $terms; }
/** * Get the array of objects terms * * @param $type A type of term to display * * @return $terms mixed|array * * @since 1.3.1 */ function yit_get_terms($case, $taxonomy, $instance = false) { $exclude = apply_filters('yith_wcan_exclude_terms', array(), $instance); $include = apply_filters('yith_wcan_include_terms', array(), $instance); $reordered = false; switch ($case) { case 'all': $terms = get_terms($taxonomy, array('hide_empty' => true, 'exclude' => $exclude)); break; case 'hierarchical': $terms = get_terms($taxonomy, array('hide_empty' => true, 'exclude' => $exclude)); if (!in_array($instance['type'], apply_filters('yith_wcan_display_type_list', array('list')))) { $terms = yit_reorder_terms_by_parent($terms, $taxonomy); $reordered = true; } break; case 'parent': $terms = get_terms($taxonomy, array('hide_empty' => true, 'parent' => false, 'exclude' => $exclude)); break; default: $args = array('hide_empty' => true, 'exclude' => $exclude, 'include' => $include); if ('parent' == $instance['display']) { $args['parent'] = false; } $terms = get_terms($taxonomy, $args); if ('hierarchical' == $instance['display']) { if (!in_array($instance['type'], apply_filters('yith_wcan_display_type_list', array('list')))) { $terms = yit_reorder_terms_by_parent($terms, $taxonomy); $reordered = true; } } break; } if ('product' == yith_wcan_get_option('yith_wcan_ajax_shop_terms_order', 'alphabetical') && 'hierarchical' != $instance['display'] && !is_wp_error($terms) && !$reordered) { usort($terms, 'yit_terms_sort'); } return apply_filters('yith_wcan_get_terms_list', $terms, $taxonomy, $instance); }
/** * Get the array of objects terms * * @param $type A type of term to display * * @return $terms mixed|array * * @since 1.3.1 */ function yit_get_terms($case, $taxonomy, $instance = false) { $exclude = apply_filters('yith_wcan_exclude_terms', array(), $instance); $include = apply_filters('yith_wcan_include_terms', array(), $instance); switch ($case) { case 'all': $terms = get_terms($taxonomy, array('hide_empty' => true, 'exclude' => $exclude)); break; case 'hierarchical': $terms = yit_reorder_terms_by_parent(get_terms($taxonomy, array('hide_empty' => true, 'exclude' => $exclude))); break; case 'parent': $terms = get_terms($taxonomy, array('hide_empty' => true, 'parent' => false, 'exclude' => $exclude)); break; default: $args = array('hide_empty' => true, 'exclude' => $exclude, 'include' => $include); if ('parent' == $instance['display']) { $args['parent'] = false; } $terms = get_terms($taxonomy, $args); if ('hierarchical' == $instance['display']) { $terms = yit_reorder_terms_by_parent($terms); } break; } return $terms; }