Automattic\WooCommerce\Internal\ProductAttributesLookup
LookupDataStore::get_term_ids_by_slug_cache
Get a cache of term ids by slug for a set of taxonomies, with this format:
[ 'taxonomy' => ['slug_1' => id_1, 'slug_2' => id_2, ...
], ... ]
Method of the class: LookupDataStore{}
No Hooks.
Returns
Array. A dictionary of taxonomies => dictionary of term slug => term id.
Usage
// private - for code of main (parent) class only $result = $this->get_term_ids_by_slug_cache( $taxonomies );
- $taxonomies(array) (required)
- List of taxonomies to build the cache for.
LookupDataStore::get_term_ids_by_slug_cache() LookupDataStore::get term ids by slug cache code WC 10.3.3
private function get_term_ids_by_slug_cache( $taxonomies ) {
$result = array();
foreach ( $taxonomies as $taxonomy ) {
$terms = WC()->call_function(
'get_terms',
array(
'taxonomy' => wc_sanitize_taxonomy_name( $taxonomy ),
'hide_empty' => false,
'fields' => 'id=>slug',
)
);
$result[ $taxonomy ] = array_flip( $terms );
}
return $result;
}