load_muplugin_textdomain

The timeline below displays how wordpress function load_muplugin_textdomain has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.3

/**
 * Loads the translated strings for a plugin residing in the mu-plugins directory.
 *
 * @since 3.0.0
 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
 *
 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
 *
 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
 * @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
 *                                   file resides. Default empty string.
 * @return bool True when textdomain is successfully loaded, false otherwise.
 */
function load_muplugin_textdomain($domain, $mu_plugin_rel_path = '')
{
    /** @var WP_Textdomain_Registry $wp_textdomain_registry */
    global $wp_textdomain_registry;
    if (!is_string($domain)) {
        return false;
    }
    /** 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, $locale)) {
        return true;
    }
    $path = WPMU_PLUGIN_DIR . '/' . ltrim($mu_plugin_rel_path, '/');
    $wp_textdomain_registry->set_custom_path($domain, $path);
    return load_textdomain($domain, $path . '/' . $mofile, $locale);
}

WordPress Version: 6.1

/**
 * Loads the translated strings for a plugin residing in the mu-plugins directory.
 *
 * @since 3.0.0
 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
 *
 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
 *
 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
 * @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
 *                                   file resides. Default empty string.
 * @return bool True when textdomain is successfully loaded, false otherwise.
 */
function load_muplugin_textdomain($domain, $mu_plugin_rel_path = '')
{
    /** @var WP_Textdomain_Registry $wp_textdomain_registry */
    global $wp_textdomain_registry;
    /** 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, $locale)) {
        return true;
    }
    $path = WPMU_PLUGIN_DIR . '/' . ltrim($mu_plugin_rel_path, '/');
    $wp_textdomain_registry->set_custom_path($domain, $path);
    return load_textdomain($domain, $path . '/' . $mofile, $locale);
}

WordPress Version: 5.0

/**
 * Load the translated strings for a plugin residing in the mu-plugins directory.
 *
 * @since 3.0.0
 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
 *
 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
 * @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
 *                                   file resides. Default empty string.
 * @return bool True when textdomain is successfully loaded, false otherwise.
 */
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);
}

WordPress Version: 4.8

/**
 * Load the translated strings for a plugin residing in the mu-plugins directory.
 *
 * @since 3.0.0
 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
 *
 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
 * @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
 *                                   file resides. Default empty string.
 * @return bool True when textdomain is successfully loaded, false otherwise.
 */
function load_muplugin_textdomain($domain, $mu_plugin_rel_path = '')
{
    /** This filter is documented in wp-includes/l10n.php */
    $locale = apply_filters('plugin_locale', is_admin() ? get_user_locale() : get_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);
}

WordPress Version: 4.7

/**
 * Load the translated strings for a plugin residing in the mu-plugins directory.
 *
 * @since 3.0.0
 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
 *
 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
 * @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
 *                                   file resides. Default empty string.
 * @return bool True when textdomain is successfully loaded, false otherwise.
 */
function load_muplugin_textdomain($domain, $mu_plugin_rel_path = '')
{
    /** This filter is documented in wp-includes/l10n.php */
    $locale = apply_filters('plugin_locale', is_admin() ? get_user_locale() : get_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 = trailingslashit(WPMU_PLUGIN_DIR . '/' . ltrim($mu_plugin_rel_path, '/'));
    return load_textdomain($domain, $path . '/' . $mofile);
}

WordPress Version: 4.6

/**
 * Load the translated strings for a plugin residing in the mu-plugins directory.
 *
 * @since 3.0.0
 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
 *
 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
 * @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
 *                                   file resides. Default empty string.
 * @return bool True when textdomain is successfully loaded, false otherwise.
 */
function load_muplugin_textdomain($domain, $mu_plugin_rel_path = '')
{
    /** This filter is documented in wp-includes/l10n.php */
    $locale = apply_filters('plugin_locale', get_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 = trailingslashit(WPMU_PLUGIN_DIR . '/' . ltrim($mu_plugin_rel_path, '/'));
    return load_textdomain($domain, $path . '/' . $mofile);
}

WordPress Version: 3.9

/**
 * Load the translated strings for a plugin residing in the mu-plugins directory.
 *
 * @since 3.0.0
 *
 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
 * @param string $mu_plugin_rel_path Relative to WPMU_PLUGIN_DIR directory in which the .mo file resides.
 *                                   Default empty string.
 * @return bool True when textdomain is successfully loaded, false otherwise.
 */
function load_muplugin_textdomain($domain, $mu_plugin_rel_path = '')
{
    /** This filter is documented in wp-includes/l10n.php */
    $locale = apply_filters('plugin_locale', get_locale(), $domain);
    $path = trailingslashit(WPMU_PLUGIN_DIR . '/' . ltrim($mu_plugin_rel_path, '/'));
    // Load the textdomain according to the plugin first
    $mofile = $domain . '-' . $locale . '.mo';
    if ($loaded = load_textdomain($domain, $path . $mofile)) {
        return $loaded;
    }
    // Otherwise, load from the languages directory
    $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
    return load_textdomain($domain, $mofile);
}

WordPress Version: 3.7

/**
 * Load the translated strings for a plugin residing in the mu-plugins directory.
 *
 * @since 3.0.0
 *
 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
 * @param string $mu_plugin_rel_path Relative to WPMU_PLUGIN_DIR directory in which the .mo file resides.
 *                                   Default empty string.
 * @return bool True when textdomain is successfully loaded, false otherwise.
 */
function load_muplugin_textdomain($domain, $mu_plugin_rel_path = '')
{
    // duplicate_hook
    $locale = apply_filters('plugin_locale', get_locale(), $domain);
    $path = trailingslashit(WPMU_PLUGIN_DIR . '/' . ltrim($mu_plugin_rel_path, '/'));
    // Load the textdomain according to the plugin first
    $mofile = $domain . '-' . $locale . '.mo';
    if ($loaded = load_textdomain($domain, $path . $mofile)) {
        return $loaded;
    }
    // Otherwise, load from the languages directory
    $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
    return load_textdomain($domain, $mofile);
}