WordPress at Your Fingertips
function is not described

WC_CSV_Exporter::format_term_ids() public WC 3.1.0

Format term ids to names.

{} It's a method of the class: WC_CSV_Exporter{}

No Hooks.

Return

String.

Usage

$WC_CSV_Exporter = new WC_CSV_Exporter();
$WC_CSV_Exporter->format_term_ids( $term_ids, $taxonomy );
$term_ids(array) (required)
Term IDs to format.
$taxonomy(string) (required)
Taxonomy name.

Changelog

Since 3.1.0 Introduced.

Code of WC_CSV_Exporter::format_term_ids() WC 5.9.0

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