[wp-trac] [WordPress Trac] #15406: / (was: Pending posts indicator not showing in menu bar)

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 15 06:22:03 UTC 2010


#15406: /
-------------------------+--------------------------------------------------
 Reporter:  iign         |       Owner:                
     Type:  enhancement  |      Status:  new           
 Priority:  normal       |   Milestone:  Future Release
Component:  UI           |     Version:  3.0.1         
 Severity:  trivial      |    Keywords:  2nd-opinion   
-------------------------+--------------------------------------------------

Comment(by somatic):

 Not sure how to integrate this code into the core menu functions, but
 here's a workaround I'm currently using, which should demonstrate what's
 missing in the current menu output:


 {{{
 add_filter( 'add_menu_classes', 'show_pending_number');
 function show_pending_number( $menu ) {
     $type = "animals";
     $status = "pending";
     $num_posts = wp_count_posts( $type, 'readable' );
     $pending_count = 0;
     if ( !empty($num_posts->$status) )
         $pending_count = $num_posts->$status;

     // build string to match in $menu array
     if ($type == 'post') {
         $menu_str = 'edit.php';
     // support custom post types
     } else {
         $menu_str = 'edit.php?post_type=' . $type;
     }

     // loop through $menu items, find match, add indicator
     foreach( $menu as $menu_key => $menu_data ) {
         if( $menu_str != $menu_data[2] )
             continue;
         $menu[$menu_key][0] .= " <span class='update-plugins
 count-$pending_count'><span class='plugin-count'>" .
 number_format_i18n($pending_count) . '</span></span>';
     }
     return $menu;
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15406#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list