Last active
September 25, 2018 20:39
-
-
Save ryelle/4d0fd05f63d09c4dcaf224ccda11fd1e to your computer and use it in GitHub Desktop.
Switch the language of the site based on a query param, ex: `site.com/wp-admin?l=en_GB`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin: Quick Langauge Switcher | |
| * Note, this only sets the site language, if your user has a user-specific language set, it won't change. | |
| */ | |
| // sv_SE, ja, ko_KR, ar, he_IL | |
| function kdwan_switch_language( $locale ) { | |
| if ( isset( $_GET['l'] ) ) { | |
| return sanitize_key( $_GET['l'] ); | |
| } | |
| return $locale; | |
| } | |
| add_filter( 'locale', 'kdwan_switch_language' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment