mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Eliminate a db query when building the admin menu for non-privileged users.
Users who cannot `edit_posts` do not see the Comments nav item anyway, so don't bother running a query that gets a comment count to display in the menu. Props bordoni, johnbillion. Fixes #19372. Built from https://develop.svn.wordpress.org/trunk@35691 git-svn-id: http://core.svn.wordpress.org/trunk@35655 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
31219ee677
commit
b17cb707dc
@ -67,10 +67,21 @@ $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-to
|
||||
|
||||
// $menu[20] = Pages
|
||||
|
||||
$awaiting_mod = wp_count_comments();
|
||||
$awaiting_mod = $awaiting_mod->moderated;
|
||||
$menu[25] = array( sprintf( __('Comments %s'), "<span class='awaiting-mod count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top menu-icon-comments', 'menu-comments', 'dashicons-admin-comments' );
|
||||
unset($awaiting_mod);
|
||||
// Avoid the comment count query for users who cannot edit_posts.
|
||||
if ( current_user_can( 'edit_posts' ) ) {
|
||||
$awaiting_mod = wp_count_comments();
|
||||
$awaiting_mod = $awaiting_mod->moderated;
|
||||
$menu[25] = array(
|
||||
sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count">' . number_format_i18n( $awaiting_mod ) . '</span></span>' ),
|
||||
'edit_posts',
|
||||
'edit-comments.php',
|
||||
'',
|
||||
'menu-top menu-icon-comments',
|
||||
'menu-comments',
|
||||
'dashicons-admin-comments',
|
||||
);
|
||||
unset( $awaiting_mod );
|
||||
}
|
||||
|
||||
$submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), 'edit_posts', 'edit-comments.php' );
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-beta4-35690';
|
||||
$wp_version = '4.4-beta4-35691';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user