Looks like the new hook is “dashboard_glance_items”. This works, but I’d love a way to add the defined CPT icon instead of a generic page, post, or comment icon. Also, since the icon is styled from .post-count a:before
, I can’t add an additional link on the item to view only pending items.
Here is my first pass at adding CPTs to the “At a Glance” section (screenshot):
// Add custom taxonomies and custom post types counts to dashboard
add_action( 'dashboard_glance_items', 'my_add_cpt_to_dashboard' );
function my_add_cpt_to_dashboard() {
$showTaxonomies = 1;
// Custom taxonomies counts
if ($showTaxonomies) {
$taxonomies = get_taxonomies( array( '_builtin' => false ), 'objects' );
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, $num_terms );
$associated_post_type = $taxonomy->object_type;
if ( current_user_can( 'manage_categories' ) ) {
$output = '<a href="edit-tags.php?taxonomy=' . $taxonomy->name . '&post_type=' . $associated_post_type[0] . '">' . $num . ' ' . $text .'</a>';
}
echo '<li class="taxonomy-count">' . $output . ' </li>';
}
}
// Custom post types counts
$post_types = get_post_types( array( '_builtin' => false ), 'objects' );
foreach ( $post_types as $post_type ) {
if($post_type->show_in_menu==false) {
continue;
}
$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, $num_posts->publish );
if ( current_user_can( 'edit_posts' ) ) {
$output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $num . ' ' . $text . '</a>';
}
// pending items count
// if ( $num_posts->pending > 0 ) {
// $num = number_format_i18n( $num_posts->pending );
// $text = _n( $post_type->labels->singular_name . ' pending', $post_type->labels->name . ' pending', $num_posts->pending );
// if ( current_user_can( 'edit_posts' ) ) {
// $output .= '<a class="waiting" href="edit.php?post_status=pending&post_type=' . $post_type->name . '">' . $num . ' pending</a>';
// }
// }
echo '<li class="page-count ' . $post_type->name . '-count">' . $output . '</td>';
}
}
]]>https://www.ads-software.com/plugins/wp-slimstat/
]]>How do I make Ajax Report Comments not show on my dashboard under “Right Now”?
Please Help
]]>How do I make Ajax Report Comments not show on my dashboard under “Right Now”?
Please Help
[No bumping. If it’s that urgent, consider hiring someone.]
]]>Any advice on this?
]]>Thank you below is the code I am using so far
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News';
$submenu['edit.php'][10][0] = 'Add News';
$submenu['edit.php'][16][0] = 'News Tags';
echo '';
}
function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'News';
$labels->singular_name = 'News';
$labels->add_new = 'Add News';
$labels->add_new_item = 'Add News';
$labels->edit_item = 'Edit News';
$labels->new_item = 'News';
$labels->view_item = 'View News';
$labels->search_items = 'Search News';
$labels->not_found = 'No News found';
$labels->not_found_in_trash = 'No News found in Trash';
}
add_action( 'init', 'change_post_object_label' );
add_action( 'admin_menu', 'change_post_menu_label' );
]]>Is there a problem with the latest version of WordPress?
https://www.ads-software.com/extend/plugins/wp-slimstat/
]]>After your latest update of the plugin the page Right Now is only showing 6 rows and the remaining I need scroll to view. I assume this is a small bug in the latest version we got today.
https://www.ads-software.com/extend/plugins/wp-slimstat/
]]>https://www.ads-software.com/extend/plugins/wp-slimstat/
]]>