wp_admin_bar_comments_menu

Add edit comments link with awaiting moderation count bubble.

Description

wp_admin_bar_comments_menu( (WP_Admin_Bar) $wp_admin_bar ); 

Parameters (1)

0. $wp_admin_bar (WP_Admin_Bar)
The wp admin bar.

Usage

  1. if ( !function_exists( 'wp_admin_bar_comments_menu' ) ) { 
  2. require_once ABSPATH . WPINC . '/admin-bar.php'; 
  3.  
  4. // The wp admin bar. 
  5. $wp_admin_bar = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_admin_bar_comments_menu($wp_admin_bar); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/admin-bar.php  
  1. function wp_admin_bar_comments_menu( $wp_admin_bar ) { 
  2. if ( !current_user_can('edit_posts') ) 
  3. return; 
  4.  
  5. $awaiting_mod = wp_count_comments(); 
  6. $awaiting_mod = $awaiting_mod->moderated; 
  7. $awaiting_text = sprintf( _n( '%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod ), number_format_i18n( $awaiting_mod ) ); 
  8.  
  9. $icon = '<span class="ab-icon"></span>'; 
  10. $title = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>'; 
  11. $title .= '<span class="screen-reader-text">' . $awaiting_text . '</span>'; 
  12.  
  13. $wp_admin_bar->add_menu( array( 
  14. 'id' => 'comments',  
  15. 'title' => $icon . $title,  
  16. 'href' => admin_url('edit-comments.php'),  
  17. ) );