wc_get_product_visibility_term_ids()
Get full list of product visibility term ids.
Хуков нет.
Возвращает
int[].
Использование
wc_get_product_visibility_term_ids();
Список изменений
| С версии 3.0.0 | Введена. |
Код wc_get_product_visibility_term_ids() wc get product visibility term ids WC 10.5.0
function wc_get_product_visibility_term_ids() {
if ( ! taxonomy_exists( 'product_visibility' ) ) {
wc_doing_it_wrong( __FUNCTION__, 'wc_get_product_visibility_term_ids should not be called before taxonomies are registered (woocommerce_after_register_post_type action).', '3.1' );
return array();
}
static $term_ids = array();
// The static variable doesn't work well with unit tests.
if ( count( $term_ids ) > 0 && ! class_exists( 'WC_Unit_Tests_Bootstrap' ) ) {
return $term_ids;
}
$term_ids = array_map(
'absint',
wp_parse_args(
wp_list_pluck(
get_terms(
array(
'taxonomy' => 'product_visibility',
'hide_empty' => false,
)
),
'term_taxonomy_id',
'name'
),
array(
'exclude-from-catalog' => 0,
'exclude-from-search' => 0,
'featured' => 0,
'outofstock' => 0,
'rated-1' => 0,
'rated-2' => 0,
'rated-3' => 0,
'rated-4' => 0,
'rated-5' => 0,
)
)
);
return $term_ids;
}