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,
...

], ... ]

Метод класса: LookupDataStore{}

Хуков нет.

Возвращает

Массив. A dictionary of taxonomies => dictionary of term slug => term id.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_term_ids_by_slug_cache( $taxonomies );
$taxonomies(массив) (обязательный)
List of taxonomies to build the cache for.

Код LookupDataStore::get_term_ids_by_slug_cache() 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;
}