ACF_Admin_Post_Types::render_admin_table_column_taxonomiespublicACF 6.1

Renders the taxonomies attached to the post type in the list table.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$ACF_Admin_Post_Types = new ACF_Admin_Post_Types();
$ACF_Admin_Post_Types->render_admin_table_column_taxonomies( $post_type );
$post_type(массив) (обязательный)
The main post type array.

Список изменений

С версии 6.1 Введена.

Код ACF_Admin_Post_Types::render_admin_table_column_taxonomies() ACF 6.4.2

public function render_admin_table_column_taxonomies( $post_type ) {
	$taxonomies = array();
	$labels     = array();

	if ( is_array( $post_type['taxonomies'] ) ) {
		$taxonomies = $post_type['taxonomies'];
	}

	$acf_taxonomies = acf_get_internal_post_type_posts( 'acf-taxonomy' );

	foreach ( $acf_taxonomies as $acf_taxonomy ) {
		if ( is_array( $acf_taxonomy['object_type'] ) && in_array( $post_type['post_type'], $acf_taxonomy['object_type'], true ) ) {
			$taxonomies[] = $acf_taxonomy['taxonomy'];
		}
	}

	$taxonomies = array_unique( $taxonomies );

	foreach ( $taxonomies as $tax_slug ) {
		$taxonomy = get_taxonomy( $tax_slug );

		if ( ! is_object( $taxonomy ) || empty( $taxonomy->label ) ) {
			continue;
		}

		$labels[] = $taxonomy->label;
	}

	if ( empty( $labels ) ) {
		echo '<span class="acf-emdash" aria-hidden="true">—</span>';
		echo '<span class="screen-reader-text">' . esc_html__( 'No taxonomies', 'acf' ) . '</span>';
		return;
	}

	$limit         = 3;
	$shown_labels  = array_slice( $labels, 0, $limit );
	$hidden_labels = array_slice( $labels, $limit );
	$text          = implode( ', ', $shown_labels );

	if ( ! empty( $hidden_labels ) ) {
		$text .= ', <span class="acf-more-items acf-js-tooltip" title="' . implode( ', ', $hidden_labels ) . '">+' . count( $hidden_labels ) . '</span>';
	}

	echo acf_esc_html( $text );
}