Skip to content

Instantly share code, notes, and snippets.

@enqtran
Last active May 5, 2017 04:13
Show Gist options
  • Save enqtran/d5199f756e15d51d193e27688557b291 to your computer and use it in GitHub Desktop.
Save enqtran/d5199f756e15d51d193e27688557b291 to your computer and use it in GitHub Desktop.
/**
* show bubble news
*/
if ( !function_exists( 'add_news_menu_bubble' ) ) {
function add_news_menu_bubble() {
if ( current_user_can('administrator') ) {
global $menu;
$count = wp_count_posts( $post_type ='news' );
$private_count = $count->pending;
if ( $count ) {
foreach ( $menu as $key => $value ) {
if ( $menu[$key][2] == 'edit.php?post_type=news' ) {
$menu[$key][0] .= " <span class='update-plugins count-".$private_count."'><span class='plugin-count'>" . $private_count . "</span></span>";
return;
}
}
}
}
}
add_action( 'admin_menu', 'add_news_menu_bubble' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment