WordPress.org

Make WordPress Core

Ticket #32366: 32366.diff

File 32366.diff, 1.1 KB (added by chacha102, 6 years ago)

Introduce 'disable_admin_menu_comment_count' filter

  • wp-admin/menu.php

    diff --git wp-admin/menu.php wp-admin/menu.php
    index 64f8019..1eb27a9 100644
    $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-to 
    6969
    7070// Avoid the comment count query for users who cannot edit_posts.
    7171if ( current_user_can( 'edit_posts' ) ) {
    72         $awaiting_mod = wp_count_comments();
    73         $awaiting_mod = $awaiting_mod->moderated;
     72
     73        $count_string = '';
     74        if ( ! apply_filters( 'disable_admin_menu_comment_count', false ) ) {
     75                $awaiting_mod = wp_count_comments();
     76                $awaiting_mod = $awaiting_mod->moderated;
     77                $count_string = '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count">' . number_format_i18n( $awaiting_mod ) . '</span></span>';
     78        }
     79
    7480        $menu[25] = array(
    75                 sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count">' . number_format_i18n( $awaiting_mod ) . '</span></span>' ),
     81                sprintf( __( 'Comments %s' ), $count_string ),
    7682                'edit_posts',
    7783                'edit-comments.php',
    7884                '',