On this page
wp_admin_bar_comments_menu( WP_Admin_Bar $wp_admin_bar )
Adds edit comments link with awaiting moderation count bubble.
Parameters
$wp_admin_barWP_Admin_Bar Required-
The WP_Admin_Bar instance.
Source
File: wp-includes/admin-bar.php. View all references
function wp_admin_bar_comments_menu( $wp_admin_bar ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
$awaiting_mod = wp_count_comments();
$awaiting_mod = $awaiting_mod->moderated;
$awaiting_text = sprintf(
/* translators: %s: Number of comments. */
_n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_mod ),
number_format_i18n( $awaiting_mod )
);
$icon = '<span class="ab-icon" aria-hidden="true"></span>';
$title = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>';
$title .= '<span class="screen-reader-text comments-in-moderation-text">' . $awaiting_text . '</span>';
$wp_admin_bar->add_node(
array(
'id' => 'comments',
'title' => $icon . $title,
'href' => admin_url( 'edit-comments.php' ),
)
);
}
Related
Uses
| Uses | Description |
|---|---|
| _n() wp-includes/l10n.php | Translates and retrieves the singular or plural form based on the supplied number. |
| WP_Admin_Bar::add_node() wp-includes/class-wp-admin-bar.php | Adds a node to the menu. |
| wp_count_comments() wp-includes/comment.php | Retrieves the total comment counts for the whole site or a single post. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| number_format_i18n() wp-includes/functions.php | Converts float number to format based on the locale. |
| admin_url() wp-includes/link-template.php | Retrieves the URL to the admin area for the current site. |
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu