Skip to content

Instantly share code, notes, and snippets.

@mayukojpn
Created July 10, 2017 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mayukojpn/03599525709b8f154be744457d00381e to your computer and use it in GitHub Desktop.
Save mayukojpn/03599525709b8f154be744457d00381e to your computer and use it in GitHub Desktop.
[Bogo] Get network term translation
<?php
/*
Plugin Name: Bogo Multisite Misc
*/
add_action( 'init', 'bogo_multisite_init' );
function bogo_multisite_get_bloginfo ( $show = '' ) {
$blog_id = get_current_blog_id();
if ( bogo_get_default_locale() == get_locale() ) {
return get_bloginfo ( $show );
}
else {
return _x( 'blog'.$show, 'blog'.$show, 'bogo-'.$blog_id );
}
}
function bogo_multisite_init () {
if ( ! is_multisite() ) {
return;
}
$sites = get_sites();
$locale = get_locale();
$dir = path_join( WP_LANG_DIR, 'bogo' );
foreach ( $sites as $site ) {
$blog_id = $site->blog_id;
$mo_file = sprintf( '%d-%s.mo', $blog_id, $locale );
$mo_file = path_join( $dir, $mo_file );
if ( file_exists( $mo_file ) ) {
// this brunch cannot avoid PHP error if mo file doesn't exist.
load_textdomain( 'bogo-'.$blog_id, $mo_file );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment