Skip to content

Instantly share code, notes, and snippets.

@alessandrotesoro
Created May 15, 2019 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alessandrotesoro/43fd9b220e2cfec00a9f2d541d80dd5e to your computer and use it in GitHub Desktop.
Save alessandrotesoro/43fd9b220e2cfec00a9f2d541d80dd5e to your computer and use it in GitHub Desktop.
Add custom menu bubble notification to WordPress admin
function pno_show_pending_listings_count_bubble() {
global $menu;
$pending_count = '5';
$listings_menu_item = wp_list_filter( $menu, [ 2 => 'edit.php?post_type=listings' ] );
if ( ! empty( $listings_menu_item ) && is_array( $listings_menu_item ) ) {
$menu[ key( $listings_menu_item ) ][0] .= " <span class='awaiting-mod update-plugins count-" . esc_attr( $pending_count ) . "'><span class='pending-count'>" . absint( number_format_i18n( $pending_count ) ) . '</span></span>';
}
}
add_action( 'admin_menu', 'pno_show_pending_listings_count_bubble' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment