You appear to be a bot. Output may be restricted
Description
Format term ids to names.
Usage
$string = WC_CSV_Exporter::format_term_ids( $term_ids, $taxonomy );
Parameters
- $term_ids
- ( array ) required – Term IDs to format.
- $taxonomy
- ( string ) required – Taxonomy name.
Returns
string
Source
File name: woocommerce/includes/export/abstract-wc-csv-exporter.php
Lines:
1 to 41 of 41
public function format_term_ids( $term_ids, $taxonomy ) { $term_ids = wp_parse_id_list( $term_ids ); if ( ! count( $term_ids ) ) { return ''; } $formatted_terms = array(); if ( is_taxonomy_hierarchical( $taxonomy ) ) { foreach ( $term_ids as $term_id ) { $formatted_term = array(); $ancestor_ids = array_reverse( get_ancestors( $term_id, $taxonomy ) ); foreach ( $ancestor_ids as $ancestor_id ) { $term = get_term( $ancestor_id, $taxonomy ); if ( $term && ! is_wp_error( $term ) ) { $formatted_term[] = $term->name; } } $term = get_term( $term_id, $taxonomy ); if ( $term && ! is_wp_error( $term ) ) { $formatted_term[] = $term->name; } $formatted_terms[] = implode( ' > ', $formatted_term ); } } else { foreach ( $term_ids as $term_id ) { $term = get_term( $term_id, $taxonomy ); if ( $term && ! is_wp_error( $term ) ) { $formatted_terms[] = $term->name; } } } return $this->implode_values( $formatted_terms ); }