WordPress.org

Make WordPress Core

Ticket #29783: user-language-admin-toolbar.php

File user-language-admin-toolbar.php, 682 bytes (added by swissspidy, 9 months ago)
Line 
1<?php
2/*
3Plugin Name: User Language Admin Toolbar
4Plugin URI: https://core.trac.wordpress.org/ticket/26511
5Description: Test plugin for #26511 and #29783
6Author: Pascal Birchler
7Author URI: https://pascalbirchler.com
8Version: 1.0
9*/
10
11
12add_action( 'admin_init', function () {
13        switch_to_locale( get_user_locale() );
14}, 0 );
15
16add_action( 'template_redirect', function () {
17        switch_to_locale( get_user_locale() );
18}, 0 );
19
20add_action( 'template_redirect', function () {
21        restore_previous_locale();
22}, 1 );
23
24add_action( 'wp_footer', function () {
25        switch_to_locale( get_user_locale() );
26}, 999 );
27
28add_action( 'add_admin_bar_menus', function () {
29        restore_previous_locale();
30}, 1001 );