ACF_Admin_Taxonomies::render_admin_table_column_num_termspublicACF 6.1

Renders the number of terms created for 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_num_terms( $taxonomy );
$taxonomy(массив) (обязательный)
The main taxonomy array.

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

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

Код ACF_Admin_Taxonomies::render_admin_table_column_num_terms() ACF 6.4.2

public function render_admin_table_column_num_terms( $taxonomy ) {
	$no_terms  = '<span class="acf-emdash" aria-hidden="true">—</span>';
	$no_terms .= '<span class="screen-reader-text">' . esc_html__( 'No terms', 'acf' ) . '</span>';

	// WP doesn't count terms for taxonomies that don't exist and instead returns WP_Error.
	if ( empty( $taxonomy['active'] ) || 'trash' === get_post_status( $taxonomy['ID'] ) ) {
		echo acf_esc_html( $no_terms );
		return;
	}

	$num_terms = wp_count_terms(
		array(
			'taxonomy'   => $taxonomy['taxonomy'],
			'hide_empty' => false,
			'parent'     => 0,
		)
	);

	if ( ! $num_terms || ! is_numeric( $num_terms ) ) {
		echo acf_esc_html( $no_terms );
		return;
	}

	printf(
		'<a href="%s">%s</a>',
		esc_url( admin_url( 'edit-tags.php?taxonomy=' . $taxonomy['taxonomy'] ) ),
		esc_html( number_format_i18n( $num_terms ) )
	);
}