ACF_Admin_Taxonomies::render_admin_table_column_num_terms
Renders the number of terms created for the taxonomy in the list table.
Method of the class: ACF_Admin_Taxonomies{}
No Hooks.
Returns
null. Nothing (null).
Usage
$ACF_Admin_Taxonomies = new ACF_Admin_Taxonomies(); $ACF_Admin_Taxonomies->render_admin_table_column_num_terms( $taxonomy );
- $taxonomy(array) (required)
- The main taxonomy array.
Changelog
| Since 6.1 | Introduced. |
ACF_Admin_Taxonomies::render_admin_table_column_num_terms() ACF Admin Taxonomies::render admin table column num terms code ACF 6.8.8
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 ) )
);
}