By default in a network install, when viewing a sub-site, the sub-site language is used for the admin bar (toolbar).
How can I have the admin bar (toolbar) always use the language of the user?
By default in a network install, when viewing a sub-site, the sub-site language is used for the admin bar (toolbar).
How can I have the admin bar (toolbar) always use the language of the user?
Until there is a fix for it in Wordpress Core you can use this 'dirty' way:
Switch to user locale before admin bar items are processed:
add_filter( 'admin_bar_menu', 'ws390690_admin_bar_in_user_locale', 10, 1 );
function ws390690_admin_bar_in_user_locale($wp_admin_bar){
switch_to_locale( get_user_locale() );
return $wp_admin_bar;
}
Switch back to site locale after admin bar has been rendered:
add_filter( 'wp_after_admin_bar_render', 'ws390690_admin_bar_in_user_locale_back', 10, 2 );
function ws390690_admin_bar_in_user_locale_back(){
restore_previous_locale();
}
As mentioned by @henrywright, its also in works here https://core.trac.wordpress.org/ticket/38643