Skip to content

Instantly share code, notes, and snippets.

@crossreftech
Last active August 29, 2015 13:56
Show Gist options
  • Save crossreftech/9203889 to your computer and use it in GitHub Desktop.
Save crossreftech/9203889 to your computer and use it in GitHub Desktop.
<?php
// Add Custom Post Type Taxonomies To At A Glance Dashboard Widget
function add_post_type_tax_to_right_now() {
$args = array(
'public' => true ,
'_builtin' => false
);
$output = 'object';
$operator = 'and';
$taxonomies = get_taxonomies( $args , $output , $operator );
foreach( $taxonomies as $taxonomy ) {
$num_terms = wp_count_terms( $taxonomy->name );
$num = number_format_i18n( $num_terms );
$text = _n( $taxonomy->labels->name, $taxonomy->labels->name , intval( $num_terms ));
if ( current_user_can( 'manage_categories' ) ) {
$cpt_tax = $taxonomy->name;
}
echo '<li class="post-count"><tr><a href="edit-tags.php?taxonomy='.$cpt_tax.'"><td class="first b b-' . $taxonomy->name . '"></td>' . $num . '&nbsp;<td class="t ' . $taxonomy->name . '">' . $text . '</td></a></tr></li>';
}
}
add_action( 'dashboard_glance_items' , 'add_post_type_tax_to_right_now' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment