Pending Review Count in the Admin Menu
Shows a red count bubble on Posts, Pages and custom post types when items are waiting for review, like WordPress does for comments.
Opens WPIDE on
Code
add_action( 'admin_menu', function () {
global $menu;
if ( ! current_user_can( 'edit_others_posts' ) || ! is_array( $menu ) ) {
return;
}
foreach ( $menu as $index => $item ) {
if ( empty( $item[2] ) ) {
continue;
}
if ( 'edit.php' === $item[2] ) {
$post_type = 'post';
} elseif ( 0 === strpos( $item[2], 'edit.php?post_type=' ) ) {
$post_type = substr( $item[2], strlen( 'edit.php?post_type=' ) );
} else {
continue;
}
if ( ! post_type_exists( $post_type ) ) {
continue;
}
$pending = (int) wp_count_posts( $post_type )->pending;
if ( $pending > 0 ) {
$menu[ $index ][0] .= sprintf( ' <span class="awaiting-mod count-%1$d"><span class="pending-count">%1$d</span></span>', $pending );
}
}
}, 999 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.