Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness. Use get_translations_for_domain() instead.

_load_textdomain_just_in_time() WordPress Function

The load_textdomain_just_in_time() function was introduced in WordPress 4.6.0. It allows for the loading of a translation file just in time when a translation is needed, instead of loading all translation files upfront. This can improve performance, especially on sites with a large number of translated strings.

_load_textdomain_just_in_time( string $domain ) #

Loads plugin and theme textdomains just-in-time.


Description

When a textdomain is encountered for the first time, we try to load the translation file from wp-content/languages, removing the need to call load_plugin_texdomain() or load_theme_texdomain().

Top ↑

See also


Top ↑

Parameters

$domain

(string)(Required)Text domain. Unique identifier for retrieving translated strings.


Top ↑

Return

(bool) True when the textdomain is successfully loaded, false otherwise.


Top ↑

Source

File: wp-includes/l10n.php

function _load_textdomain_just_in_time( $domain ) {
	global $l10n_unloaded;

	$l10n_unloaded = (array) $l10n_unloaded;

	// Short-circuit if domain is 'default' which is reserved for core.
	if ( 'default' === $domain || isset( $l10n_unloaded[ $domain ] ) ) {
		return false;
	}

	$translation_path = _get_path_to_translation( $domain );
	if ( false === $translation_path ) {
		return false;
	}

	return load_textdomain( $domain, $translation_path );
}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.