ACF_Admin_Taxonomies::render_admin_table_column_post_types
Renders the post types attached to the taxonomy in the list table.
Метод класса: ACF_Admin_Taxonomies{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$ACF_Admin_Taxonomies = new ACF_Admin_Taxonomies(); $ACF_Admin_Taxonomies->render_admin_table_column_post_types( $taxonomy );
- $taxonomy(массив) (обязательный)
- The main taxonomy array.
Список изменений
| С версии 6.1 | Введена. |
Код ACF_Admin_Taxonomies::render_admin_table_column_post_types() ACF Admin Taxonomies::render admin table column post types ACF 6.4.2
public function render_admin_table_column_post_types( $taxonomy ) {
$post_types = get_post_types( array(), 'objects' );
$labels = array();
$object_types = array();
if ( ! empty( $taxonomy['object_type'] ) ) {
$object_types = (array) $taxonomy['object_type'];
}
foreach ( $object_types as $post_type_slug ) {
if ( ! isset( $post_types[ $post_type_slug ] ) ) {
continue;
}
$post_type = $post_types[ $post_type_slug ];
if ( empty( $post_type->label ) ) {
continue;
}
$labels[] = $post_type->label;
}
$acf_post_types = acf_get_internal_post_type_posts( 'acf-post-type' );
foreach ( $acf_post_types as $acf_post_type ) {
if ( is_array( $acf_post_type['taxonomies'] ) && in_array( $taxonomy['taxonomy'], $acf_post_type['taxonomies'], true ) ) {
$labels[] = $acf_post_type['title'];
}
}
if ( empty( $labels ) ) {
echo '<span class="acf-emdash" aria-hidden="true">—</span>';
echo '<span class="screen-reader-text">' . esc_html__( 'No post types', 'acf' ) . '</span>';
return;
}
$labels = array_unique( $labels );
$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 );
}