<?php
/*
Plugin Name: User Language Admin Toolbar
Plugin URI: https://core.trac.wordpress.org/ticket/26511
Description: Test plugin for #26511 and #29783
Author: Pascal Birchler
Author URI: https://pascalbirchler.com
Version: 1.0
*/


add_action( 'admin_init', function () {
	switch_to_locale( get_user_locale() );
}, 0 );

add_action( 'template_redirect', function () {
	switch_to_locale( get_user_locale() );
}, 0 );

add_action( 'template_redirect', function () {
	restore_previous_locale();
}, 1 );

add_action( 'wp_footer', function () {
	switch_to_locale( get_user_locale() );
}, 999 );

add_action( 'add_admin_bar_menus', function () {
	restore_previous_locale();
}, 1001 );
