Automattic\WooCommerce\Internal\ProductAttributesLookup

LookupDataStore::get_term_ids_by_slug_cache()privateWC 1.0

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.

Return

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() code WC 8.7.0

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;
}