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
|
// $menu[20] = Pages
|
||||||
|
|
||||||
$awaiting_mod = wp_count_comments();
|
// Avoid the comment count query for users who cannot edit_posts.
|
||||||
$awaiting_mod = $awaiting_mod->moderated;
|
if ( current_user_can( 'edit_posts' ) ) {
|
||||||
$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' );
|
$awaiting_mod = wp_count_comments();
|
||||||
unset($awaiting_mod);
|
$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' );
|
$submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), 'edit_posts', 'edit-comments.php' );
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue