src/class-extended-cpt-admin.php
public function col_taxonomy( string $taxonomy, array $args ) {

		global $post;

		$terms = get_the_terms( $post, $taxonomy );
		$tax   = get_taxonomy( $taxonomy );

		if ( is_wp_error( $terms ) ) {
			echo esc_html( $terms->get_error_message() );
			return;
		}

		if ( empty( $terms ) ) {
			printf(
				'<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
				esc_html( $tax->labels->no_terms )
			);
			return;
		}

		$out = [];

		foreach ( $terms as $term ) {

			if ( $args['link'] ) {

				switch ( $args['link'] ) {
					case 'view':
						if ( $tax->public ) {
							// https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1096
							// @codingStandardsIgnoreStart
							$out[] = sprintf(
								'<a href="%1$s">%2$s</a>',
								esc_url( get_term_link( $term ) ),
								esc_html( $term->name )
							);
							// @codingStandardsIgnoreEnd
						} else {
							$out[] = esc_html( $term->name );
						}
						break;
					case 'edit':
						if ( current_user_can( $tax->cap->edit_terms ) ) {
							$out[] = sprintf(
								'<a href="%1$s">%2$s</a>',
								esc_url( get_edit_term_link( $term, $taxonomy, $post->post_type ) ),
								esc_html( $term->name )
							);
						} else {
							$out[] = esc_html( $term->name );
						}
						break;
					case 'list':
						$link = add_query_arg( [
							'post_type' => $post->post_type,
							$taxonomy   => $term->slug,
						], admin_url( 'edit.php' ) );
						$out[] = sprintf(
							'<a href="%1$s">%2$s</a>',
							esc_url( $link ),
							esc_html( $term->name )
						);
						break;
				}
			} else {

				$out[] = esc_html( $term->name );

			}
		}

		echo implode( ', ', $out ); // WPCS: XSS ok.

	}
public function col_taxonomy( string $taxonomy, array $args ) {

		global $post;

		$terms = get_the_terms( $post, $taxonomy );
		$tax   = get_taxonomy( $taxonomy );

		if ( is_wp_error( $terms ) ) {
			echo esc_html( $terms->get_error_message() );
			return;
		}

		if ( empty( $terms ) ) {
			printf(
				'<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
				esc_html( $tax->labels->no_terms )
			);
			return;
		}

		$out = [];

		foreach ( $terms as $term ) {

			if ( $args['link'] ) {

				switch ( $args['link'] ) {
					case 'view':
						if ( $tax->public ) {
							// https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1096
							// @codingStandardsIgnoreStart
							$out[] = sprintf(
								'<a href="%1$s">%2$s</a>',
								esc_url( get_term_link( $term ) ),
								esc_html( $term->name )
							);
							// @codingStandardsIgnoreEnd
						} else {
							$out[] = esc_html( $term->name );
						}
						break;
					case 'edit':
						if ( current_user_can( $tax->cap->edit_terms ) ) {
							$out[] = sprintf(
								'<a href="%1$s">%2$s</a>',
								esc_url( get_edit_term_link( $term, $taxonomy, $post->post_type ) ),
								esc_html( $term->name )
							);
						} else {
							$out[] = esc_html( $term->name );
						}
						break;
					case 'list':
						$link = add_query_arg( [
							'post_type' => $post->post_type,
							$taxonomy   => $term->slug,
						], admin_url( 'edit.php' ) );
						$out[] = sprintf(
							'<a href="%1$s">%2$s</a>',
							esc_url( $link ),
							esc_html( $term->name )
						);
						break;
				}
			} else {

				$out[] = esc_html( $term->name );

			}
		}

		echo implode( ', ', $out ); // WPCS: XSS ok.

	}
public function col_taxonomy ( string $ taxonomy , array $ args ) { global $ post ; $ terms = get_the_terms ( $ post , $ taxonomy ) ; $ tax = get_taxonomy ( $ taxonomy ) ; if ( is_wp_error ( $ terms ) ) { echo esc_html ( $ terms -> get_error_message ( ) ) ; return ; } if ( empty ( $ terms ) ) { printf ( '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>' , esc_html ( $ tax -> labels -> no_terms ) ) ; return ; } $ out = [ ] ; foreach ( $ terms as $ term ) { if ( $ args [ 'link' ] ) { switch ( $ args [ 'link' ] ) { case 'view' : if ( $ tax -> public ) { // https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1096 // @codingStandardsIgnoreStart $ out [ ] = sprintf ( '<a href="%1$s">%2$s</a>' , esc_url ( get_term_link ( $ term ) ) , esc_html ( $ term -> name ) ) ; // @codingStandardsIgnoreEnd } else { $ out [ ] = esc_html ( $ term -> name ) ; } break ; case 'edit' : if ( current_user_can ( $ tax -> cap -> edit_terms ) ) { $ out [ ] = sprintf ( '<a href="%1$s">%2$s</a>' , esc_url ( get_edit_term_link ( $ term , $ taxonomy , $ post -> post_type ) ) , esc_html ( $ term -> name ) ) ; } else { $ out [ ] = esc_html ( $ term -> name ) ; } break ; case 'list' : $ link = add_query_arg ( [ 'post_type' => $ post -> post_type , $ taxonomy => $ term -> slug , ] , admin_url ( 'edit.php' ) ) ; $ out [ ] = sprintf ( '<a href="%1$s">%2$s</a>' , esc_url ( $ link ) , esc_html ( $ term -> name ) ) ; break ; } } else { $ out [ ] = esc_html ( $ term -> name ) ; } } echo implode ( ', ' , $ out ) ; // WPCS: XSS ok. }
Output column data for a taxonomy's term names.

@param string $taxonomy The taxonomy name
@param array  $args     Array of arguments for this field
Output column data for a taxonomy s term names .