Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Created October 17, 2012 10:40
Show Gist options
  • Save kovshenin/3904905 to your computer and use it in GitHub Desktop.
Save kovshenin/3904905 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Language Redirect
*/
add_action( 'init', 'language_redirect_init' ) {
// Map language to blog id
$sites = array(
'default' => 1,
'en' => 2,
'de' => 2,
);
$lang = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 );
$id = array_key_exists( $lang, $sites ) ? $sites[ $lang ] : $sites['default'];
if ( get_current_blog_id() != $id ) {
wp_redirect( get_blogaddress_by_id( $id ) );
die();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment