For some time I've been using this code snippet adding both custom post types and custom taxonomies to the WP Dashboard Right Now widget:
function dashboard_right_now_content_table_end() {
$args = array(
'public' => true,
'_builtin' => false
);
$output = 'object';
$operator = 'and';
$post_types = get_post_types($args, $output, $operator);
foreach ($post_types as $post_type) {
$num_posts = wp_count_posts($post_type->name);
$num = number_format_i18n($num_posts->publish);
$text = _n($post_type->labels->singular_name, $post_type->labels->name, intval($num_posts->publish));
if (current_user_can('edit_posts')) {
$num = "<a href='edit.php?post_type=$post_type->name'>$num</a>";
$text = "<a href='edit.php?post_type=$post_type->name'>$text</a>";
}
echo '<tr><td class="first b b-' . $post_type->name . '">' . $num . '</td>';
echo '<td class="t ' . $post_type->name . '">' . $text . '</td></tr>';
}
$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->singular_name, $taxonomy->labels->name, intval($num_terms));
if (current_user_can('manage_categories')) {
$num = "<a href='edit-tags.php?taxonomy=$taxonomy->name'>$num</a>";
$text = "<a href='edit-tags.php?taxonomy=$taxonomy->name'>$text</a>";
}
echo '<tr><td class="first b b-' . $taxonomy->name . '">' . $num . '</td>';
echo '<td class="t ' . $taxonomy->name . '">' . $text . '</td></tr>';
}
}
add_action('right_now_content_table_end', 'dashboard_right_now_content_table_end');
Using this taxonomy:
function create_secondary_taxonomies() {
$labels = array(
'name' => _x('Mogelijkheden', 'taxonomy general name'),
'singular_name' => _x('Mogelijkheid', 'taxonomy singular name'),
'search_items' => __('Search Categories'),
'all_items' => __('All Categories'),
'parent_item' => __('Parent Category'),
'parent_item_colon' => __('Parent Category:'),
'edit_item' => __('Edit Category'),
'view_item' => __('View Category'),
'update_item' => __('Update Category'),
'add_new_item' => __('Add New Category'),
'new_item_name' => __('New Category Name'),
'menu_name' => __('Mogelijkheden')
);
register_taxonomy('mogelijkheden', array(
'portfolio'
), array(
'labels' => $labels,
'hierarchical' => true,
'query_var' => true,
'rewrite' => array(
'hierarchical' => true,
'slug' => 'mogelijkheden',
'with_front' => false
),
'public' => true,
'show_ui' => true,
'_builtin' => true
));
}
add_action('init', 'create_secondary_taxonomies');
This all worked great. Until recently. Currently it is still showing the custom post types, but it isn't showing the custom taxonomies anymore.
Does someone notices any errors or things that could conflict with this code perhaps?