Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'admin_menu', 'pending_posts_bubble_wpse_89028', 999 );
- function pending_posts_bubble_wpse_89028()
- {
- global $menu;
- $args = array( 'public' => true );
- $post_types = get_post_types( $args );
- unset( $post_types['attachment'] );
- foreach( $post_types as $pt )
- {
- // count posts
- $cpt_count = wp_count_posts( $pt );
- if ( $cpt_count->pending )
- {
- $suffix = ( 'post' == $pt ) ? '' : "?post_type=$pt";
- $key = recursive_array_search_php_91365( "edit.php$suffix", $menu );
- if( !$key )
- return;
- $menu[$key][0] .= sprintf(
- '<span class="update-plugins count-%1$s"><span class="plugin-count">%1$s</span></span>',
- $cpt_count->pending
- );
- }
- }
- }
- function recursive_array_search_php_91365( $needle, $haystack )
- {
- foreach( $haystack as $key => $value )
- {
- $current_key = $key;
- if(
- $needle === $value
- OR (
- is_array( $value )
- && recursive_array_search_php_91365( $needle, $value ) !== false
- )
- )
- {
- return $current_key;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement