Created
July 10, 2017 12:26
-
-
Save mayukojpn/03599525709b8f154be744457d00381e to your computer and use it in GitHub Desktop.
[Bogo] Get network term translation
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 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