为翻译的字符串加载驻留在mu-plugins目录中的插件。
原型
load_muplugin_textdomain( string $domain, string $mu_plugin_rel_path = '' )
参数
$domain
(string)
(Required)
文字域名。用于检索已翻译字符串的唯一标识符
$mu_plugin_rel_path
(string)
(Optional)
相对于.mo文件所在的WPMU_PLUGIN_DIR目录。
返回值
(bool)
成功加载textdomain时为true,否则为false。
源文件
路径:wp-includes/l10n.php
<?php
...
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
/** This filter is documented in wp-includes/l10n.php */
$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
$mofile = $domain . '-' . $locale . '.mo';
// Try to load from the languages directory first.
if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile ) ) {
return true;
}
$path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );
return load_textdomain( $domain, $path . '/' . $mofile );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/load_muplugin_textdomain/