是的,有。您可以使用admin_menu 钩子循环菜单项并添加带有通知的范围。WP对这些通知使用两个类update-plugins 和awaiting-mod. 我想,在这种情况下,第二个看起来更合适。。。
以下是一些代码:
function add_user_menu_notification() {
global $menu;
$user_count = count_users(); // get whatever count you need
$user_count = $user_count[\'avail_roles\'][\'administrator\'];
if ( $user_count ) {
foreach ( $menu as $key => $value ) {
if ( $menu[$key][2] == \'users.php\' ) {
$menu[$key][0] .= \' <span class="awaiting-mod">\' . $user_count . \'</span>\';
return;
}
}
}
}
add_action( \'admin_menu\', \'add_user_menu_notification\' );