WordPress.org

Make WordPress Core

Ticket #27831: 27831.diff

File 27831.diff, 769 bytes (added by celloexpressions, 7 years ago)

Don't display the comments toolbar item if there are no comments awaiting moderation.

  • wp-includes/admin-bar.php

     
    614614 * @param WP_Admin_Bar $wp_admin_bar
    615615 */
    616616function wp_admin_bar_comments_menu( $wp_admin_bar ) {
    617         if ( !current_user_can('edit_posts') )
     617        if ( !current_user_can('edit_posts') ) {
    618618                return;
     619        }
    619620
    620621        $awaiting_mod = wp_count_comments();
    621622        $awaiting_mod = $awaiting_mod->moderated;
     623
     624        if ( 0 === $awaiting_mod ) {
     625                return;
     626        }
     627
    622628        $awaiting_title = esc_attr( sprintf( _n( '%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod ), number_format_i18n( $awaiting_mod ) ) );
    623629
    624630        $icon  = '<span class="ab-icon"></span>';